// groupNodeSummary renders the summary for a group node. n.Topology is // expected to be of the form: group:container:hostname func groupNodeSummary(base NodeSummary, r report.Report, n report.Node) (NodeSummary, bool) { parts := strings.Split(n.Topology, ":") if len(parts) != 3 { return NodeSummary{}, false } label, ok := n.Latest.Lookup(parts[2]) if !ok { return NodeSummary{}, false } base.Label, base.Rank = label, label t, ok := r.Topology(parts[1]) if ok && t.Label != "" { if count, ok := n.Counters.Lookup(parts[1]); ok { if count == 1 { base.LabelMinor = fmt.Sprintf("%d %s", count, t.Label) } else { base.LabelMinor = fmt.Sprintf("%d %s", count, t.LabelPlural) } } } base.Shape = t.GetShape() base.Stack = true return base, true }
// NodeTables produces a list of tables (to be consumed directly by the UI) based // on the report and the node. It uses the report to get the templates for the node's // topology. func NodeTables(r report.Report, n report.Node) []report.Table { if _, ok := n.Counters.Lookup(n.Topology); ok { // This is a group of nodes, so no tables! return nil } if topology, ok := r.Topology(n.Topology); ok { return topology.TableTemplates.Tables(n) } return nil }
// NodeMetadata produces a table (to be consumed directly by the UI) based on // an a report.Node, which is (hopefully) a node in one of our topologies. func NodeMetadata(r report.Report, n report.Node) []report.MetadataRow { if _, ok := n.Counters.Lookup(n.Topology); ok { // This is a group of nodes, so no metadata! return nil } if topology, ok := r.Topology(n.Topology); ok { return topology.MetadataTemplates.MetadataRows(n) } return nil }
func baseNodeSummary(r report.Report, n report.Node) NodeSummary { t, _ := r.Topology(n.Topology) return NodeSummary{ ID: n.ID, Shape: t.GetShape(), Linkable: true, Metadata: NodeMetadata(r, n), Metrics: NodeMetrics(r, n), Tables: NodeTables(r, n), Adjacency: n.Adjacency.Copy(), } }
// NodeMetrics produces a table (to be consumed directly by the UI) based on // an a report.Node, which is (hopefully) a node in one of our topologies. func NodeMetrics(r report.Report, n report.Node) []report.MetricRow { if _, ok := n.Counters.Lookup(n.Topology); ok { // This is a group of nodes, so no metrics! return nil } topology, ok := r.Topology(n.Topology) if !ok { return nil } return topology.MetricTemplates.MetricRows(n) }
func controls(r report.Report, n report.Node) []ControlInstance { if t, ok := r.Topology(n.Topology); ok { return controlsFor(t, n.ID) } return []ControlInstance{} }
// Render implements Renderer func (t TopologySelector) Render(r report.Report, _ Decorator) report.Nodes { topology, _ := r.Topology(string(t)) return topology.Nodes }