Files
weave-scope/render/selectors.go
Paul Bellamy 3d3aed2bb3 Fixing grouped node count for filtered children nodes
Squash of:

* We have to keep all the container hostnames until the end so we can
  count how many we've filtered

* Adding tests for ContainerHostnameRenderer and PodServiceRenderer with
  filters

* Because we filter on image name we need the image name before
  filtering

* Alternative approach to passing decorators.

* Refactor out some of the decorator capture

* Don't memoise decorated calls to Render

* Fixing filtered counts on containers topology

  Tricky, because we need the filters to be silent sometimes (when they're
  in the middle), but not when they're at the top, so we take the "top"
  filter's stats. However, this means we have to compose all
  user-specified filters into a single Filter layer, so we can get all
  stats.

  There are no more Silent filters, as all filters are silent (unless they
  are at the top).

  Additionally, I clarified some of the filters as their usage/terminology
  was inconsistent and confused. Now Filter(IsFoo, ...) *keeps* only nodes
  where IsFoo is true.
2016-04-28 12:23:43 +01:00

33 lines
994 B
Go

package render
import (
"github.com/weaveworks/scope/report"
)
// TopologySelector selects a single topology from a report.
// NB it is also a Renderer!
type TopologySelector string
// Render implements Renderer
func (t TopologySelector) Render(r report.Report, _ Decorator) report.Nodes {
topology, _ := r.Topology(string(t))
return topology.Nodes
}
// Stats implements Renderer
func (t TopologySelector) Stats(r report.Report, _ Decorator) Stats {
return Stats{}
}
// The topology selectors implement a Renderer which fetch the nodes from the
// various report topologies.
var (
SelectEndpoint = TopologySelector(report.Endpoint)
SelectProcess = TopologySelector(report.Process)
SelectContainer = TopologySelector(report.Container)
SelectContainerImage = TopologySelector(report.ContainerImage)
SelectHost = TopologySelector(report.Host)
SelectPod = TopologySelector(report.Pod)
SelectService = TopologySelector(report.Service)
)