WIP: convert MapContainerImage2Name to a Renderer

This commit is contained in:
Bryan Boreham
2020-06-21 16:04:00 +00:00
parent 7163f42170
commit 28b73dba28
2 changed files with 29 additions and 22 deletions
+14
View File
@@ -158,6 +158,7 @@ type joinResults struct {
multi map[string][]string // input node ID -> output node IDs - exceptional case
}
// Create a joinResults with a starting set of nodes, that other info will be added into.
func newJoinResults(inputNodes report.Nodes) joinResults {
nodes := make(report.Nodes, len(inputNodes))
for id, n := range inputNodes {
@@ -217,6 +218,19 @@ func (ret *joinResults) addChildAndChildren(m report.Node, id string, topology s
ret.mapChild(m.ID, id)
}
func (ret *joinResults) addWithCreate(m report.Node, id string, create func() report.Node) {
result, exists := ret.nodes[id]
if !exists {
result = create()
ret.nodes[id] = result
}
ret.addUnmappedChild(m, id, result.Topology)
result = ret.nodes[id]
result.Children.UnsafeMerge(m.Children)
ret.nodes[id] = result
ret.mapChild(m.ID, id)
}
// Add a copy of n straight into the results
func (ret *joinResults) passThrough(n report.Node) {
n.Adjacency = nil // result() assumes all nodes start with no adjacencies