Merge pull request #3268 from weaveworks/optimise-withlatests

Optimise Node.WithLatests()
This commit is contained in:
Bryan Boreham
2018-07-18 14:04:35 +01:00
committed by GitHub
4 changed files with 52 additions and 15 deletions

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).
AddString(report.ContainerImage, imageNodeID)

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