From fb9e05a4f6cd6ed7f408af65fb96d31efd2f48ab Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 5 Nov 2017 00:14:34 +0000 Subject: [PATCH] Use helper to add result nodes in endpoints2Hosts.Render This means we are no longer generating a Counter for the number of endpoint sub-nodes, but it seems that data was not used. --- render/host.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/render/host.go b/render/host.go index e4bf1e3733..8bae3f133e 100644 --- a/render/host.go +++ b/render/host.go @@ -71,8 +71,6 @@ func (e endpoints2Hosts) Render(rpt report.Report, dct Decorator) report.Nodes { var ret = make(report.Nodes) var mapped = map[string]string{} // input node ID -> output node ID for _, n := range ns { - var result report.Node - var exists bool // Nodes without a hostid are treated as pseudo nodes hostNodeID, timestamp, ok := n.Latest.LookupEntry(report.HostNodeID) if !ok { @@ -80,23 +78,16 @@ func (e endpoints2Hosts) Render(rpt report.Report, dct Decorator) report.Nodes { if !ok { continue } - result, exists = ret[id] - if !exists { - result = report.MakeNode(id).WithTopology(Pseudo) - } + addToResults(n, id, ret, mapped, func() report.Node { + return report.MakeNode(id).WithTopology(Pseudo) + }) } else { id := report.MakeHostNodeID(report.ExtractHostID(n)) - result, exists = ret[id] - if !exists { - result = report.MakeNode(id).WithTopology(report.Host) - result.Latest = result.Latest.Set(report.HostNodeID, timestamp, hostNodeID) - } - result.Children = result.Children.Merge(n.Children) + addToResults(n, id, ret, mapped, func() report.Node { + return report.MakeNode(id).WithTopology(report.Host). + WithLatest(report.HostNodeID, timestamp, hostNodeID) + }) } - result.Children = result.Children.Add(n) - result.Counters = result.Counters.Add(n.Topology, 1) - ret[result.ID] = result - mapped[n.ID] = result.ID } fixupAdjancencies(ns, ret, mapped) return ret