Add method to add a single string into Sets

This avoids creating and discarding a StringSet just to pass the parameter
This commit is contained in:
Bryan Boreham
2018-07-16 20:16:59 +00:00
parent 761fafe61b
commit 0d2409c72c
5 changed files with 20 additions and 5 deletions

View File

@@ -182,10 +182,10 @@ func (r Reporter) Tag(rpt report.Report) (report.Report, error) {
// parents sets to merge into all matching container nodes
parentsSets := report.MakeSets()
parentsSets = parentsSets.Add(report.ECSTask, report.MakeStringSet(taskID))
parentsSets = parentsSets.AddString(report.ECSTask, taskID)
if serviceName, ok := ecsInfo.TaskServiceMap[taskArn]; ok {
serviceID := report.MakeECSServiceNodeID(cluster, serviceName)
parentsSets = parentsSets.Add(report.ECSService, report.MakeStringSet(serviceID))
parentsSets = parentsSets.AddString(report.ECSService, serviceID)
// in addition, make service parent of task
rpt.ECSTask.Nodes[taskID] = rpt.ECSTask.Nodes[taskID].WithParents(report.MakeSets().Add(report.ECSService, report.MakeStringSet(serviceID)))
}

View File

@@ -56,7 +56,7 @@ func (p *pod) UID() string {
}
func (p *pod) AddParent(topology, id string) {
p.parents = p.parents.Add(topology, report.MakeStringSet(id))
p.parents = p.parents.AddString(topology, id)
}
func (p *pod) State() string {

View File

@@ -357,7 +357,7 @@ func (r *Reporter) hostTopology(services []Service) report.Topology {
t := report.MakeTopology()
t.AddNode(
report.MakeNode(report.MakeHostNodeID(r.hostID)).
WithSets(report.MakeSets().Add(host.LocalNetworks, report.MakeStringSet(serviceNetwork.String()))))
WithSets(report.MakeSets().AddString(host.LocalNetworks, serviceNetwork.String())))
return t
}