Propagate multiple container values at once

This is more efficient than repeatedly inserting a single value.
This commit is contained in:
Bryan Boreham
2018-07-18 12:52:27 +00:00
parent 6ff8316a1d
commit cc79b7631e
3 changed files with 16 additions and 12 deletions
+3 -5
View File
@@ -143,11 +143,9 @@ func (r containerWithImageNameRenderer) Render(rpt report.Report) Nodes {
imageNameWithoutTag := docker.ImageNameWithoutTag(imageName)
imageNodeID := report.MakeContainerImageNodeID(imageNameWithoutTag)
c = propagateLatest(docker.ImageName, image, c)
c = propagateLatest(docker.ImageTag, image, c)
c = propagateLatest(docker.ImageSize, image, c)
c = propagateLatest(docker.ImageVirtualSize, image, c)
c = propagateLatest(docker.ImageLabelPrefix+"works.weave.role", image, c)
c.Latest = c.Latest.Propagate(image.Latest, docker.ImageName, docker.ImageTag,
docker.ImageSize, docker.ImageVirtualSize, docker.ImageLabelPrefix+"works.weave.role")
c.Parents = c.Parents.
Delete(report.ContainerImage).
Add(report.ContainerImage, report.MakeStringSet(imageNodeID))
-7
View File
@@ -115,13 +115,6 @@ func (m Map) Render(rpt report.Report) Nodes {
return output.result(input)
}
func propagateLatest(key string, from, to report.Node) report.Node {
if value, timestamp, ok := from.Latest.LookupEntry(key); ok {
to.Latest = to.Latest.Set(key, timestamp, value)
}
return to
}
// Condition is a predecate over the entire report that can evaluate to true or false.
type Condition func(report.Report) bool