mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
If no node summary generator exists for topology, do a sane default
The default sets the node label to the node ID. This is likely to not look very good, but the intent is that it creates an obvious problem, ie. that the node ID is being used as the label, rather than a silent omission or more subtle problem. Possible future work: * For single-component IDs, extract the component automatically and use that instead. * Instead of functions, in simple cases just have a LUT by topology with common behaviours like 'stack = true or false', 'label = this key in node.Latest' The latter opens up to eventually moving this info inside the report itself ala topology templates, or at least centralizing it in the source.
This commit is contained in:
@@ -73,6 +73,7 @@ var renderers = map[string]func(NodeSummary, report.Node) (NodeSummary, bool){
|
||||
report.ECSService: ecsServiceNodeSummary,
|
||||
report.Host: hostNodeSummary,
|
||||
report.Overlay: weaveNodeSummary,
|
||||
report.Endpoint: nil, // Do not render
|
||||
}
|
||||
|
||||
var templates = map[string]struct{ Label, LabelMinor string }{
|
||||
@@ -97,7 +98,14 @@ var primaryAPITopology = map[string]string{
|
||||
// MakeNodeSummary summarizes a node, if possible.
|
||||
func MakeNodeSummary(r report.Report, n report.Node) (NodeSummary, bool) {
|
||||
if renderer, ok := renderers[n.Topology]; ok {
|
||||
return renderer(baseNodeSummary(r, n), n)
|
||||
// Skip (and don't fall through to fallback) if renderer maps to nil
|
||||
if renderer != nil {
|
||||
return renderer(baseNodeSummary(r, n), n)
|
||||
}
|
||||
} else if _, ok := r.Topology(n.Topology); ok {
|
||||
summary := baseNodeSummary(r, n)
|
||||
summary.Label = n.ID // This is unlikely to look very good, but is a reasonable fallback
|
||||
return summary, true
|
||||
}
|
||||
if strings.HasPrefix(n.Topology, "group:") {
|
||||
return groupNodeSummary(baseNodeSummary(r, n), r, n)
|
||||
|
||||
Reference in New Issue
Block a user