From 2a74883cceea2af5ad277d9b25c3e2ead684545e Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Mon, 3 Apr 2017 12:47:30 -0700 Subject: [PATCH] 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. --- render/detailed/summary.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/render/detailed/summary.go b/render/detailed/summary.go index 85f1d1bca..6cde8d49a 100644 --- a/render/detailed/summary.go +++ b/render/detailed/summary.go @@ -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)