mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-24 07:46:41 +00:00
render/detailed: When summarising children, add fallback for unlisted topologies
Currently, if a topology does not have any specific info in nodeSummariesByID, any children of the node that belong to that topology will be silently omitted. This change adds a default behaviour for such topologies, with no special columns but at least it is displayed at all. Unlisted topologies are displayed after all listed ones, in arbitrary order. Note that completely bogus or other special cases (eg. topology = Pseudo) still will not be displayed as report.Topology() will fail.
This commit is contained in:
@@ -246,14 +246,37 @@ func children(r report.Report, n report.Node) []NodeSummaryGroup {
|
||||
})
|
||||
|
||||
nodeSummaryGroups := []NodeSummaryGroup{}
|
||||
// Apply specific group specs in the order they're listed
|
||||
for _, spec := range nodeSummaryGroupSpecs {
|
||||
if len(summaries[spec.topologyID]) > 0 {
|
||||
sort.Sort(nodeSummariesByID(summaries[spec.TopologyID]))
|
||||
group := spec.NodeSummaryGroup
|
||||
group.Nodes = summaries[spec.topologyID]
|
||||
nodeSummaryGroups = append(nodeSummaryGroups, group)
|
||||
delete(summaries, spec.topologyID)
|
||||
}
|
||||
}
|
||||
// As a fallback, in case a topology has no group spec defined, add any remaining at the end
|
||||
for topologyID, nodeSummaries := range summaries {
|
||||
if len(nodeSummaries) == 0 {
|
||||
continue
|
||||
}
|
||||
topology, ok := r.Topology(topologyID)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
apiTopology, ok := primaryAPITopology[topologyID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
sort.Sort(nodeSummariesByID(nodeSummaries))
|
||||
group := NodeSummaryGroup{
|
||||
ID: apiTopology,
|
||||
Label: topology.LabelPlural,
|
||||
Columns: []Column{},
|
||||
}
|
||||
nodeSummaryGroups = append(nodeSummaryGroups, group)
|
||||
}
|
||||
|
||||
return nodeSummaryGroups
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user