refactor(ish): reduce number of topology lists

Having 6 lists of topolgies in the same file is a bit much:

1. consts for topology names
2. Report type definition
3. MakeReport() Report initialisation
4. Report.Topology(name) lookup
5. Report.TopologyMap() mapping of names to topology references
6. Report.WalkPairedTopologies() iterator over topology references

We get rid of 5 and 6 by introducing a topologyNames slice. So we
are down to 5.

We replace Report.TopologyMap() with a new function,
WalkNamedTopologies, that uses topologyNames. WalkPairedTopologies()
is updated to operate in a similar fashion. Likewise for
WalkTopologies() and Topologies() - these were previously calling
Walk[Paired]Topologies, but it is clearer to simply implement them
directly.
This commit is contained in:
Matthias Radestock
2017-12-24 20:20:59 +00:00
parent 583e81d733
commit 9419c3ef5c
2 changed files with 68 additions and 64 deletions

View File

@@ -16,10 +16,10 @@ func (topologyTagger) Name() string { return "Topology" }
// Tag implements Tagger
func (topologyTagger) Tag(r report.Report) (report.Report, error) {
for name, t := range r.TopologyMap() {
r.WalkNamedTopologies(func(name string, t *report.Topology) {
for _, node := range t.Nodes {
t.AddNode(node.WithTopology(name))
}
}
})
return r, nil
}