Exemplo n.º 1
0
// AddLabels appends Docker labels to the Node from a topology.
func AddLabels(node report.Node, labels map[string]string) report.Node {
	node = node.Copy()
	for key, value := range labels {
		node = node.WithLatests(map[string]string{
			LabelPrefix + key: value,
		})
	}
	return node
}
Exemplo n.º 2
0
// MapContainerImage2Name ignores image versions
func MapContainerImage2Name(n report.Node, _ report.Networks) report.Nodes {
	// Propagate all pseudo nodes
	if n.Topology == Pseudo {
		return report.Nodes{n.ID: n}
	}

	imageName, ok := n.Latest.Lookup(docker.ImageName)
	if !ok {
		return report.Nodes{}
	}

	imageNameWithoutVersion := docker.ImageNameWithoutVersion(imageName)
	output := n.Copy()
	output.ID = report.MakeContainerImageNodeID(imageNameWithoutVersion)

	if imageID, ok := report.ParseContainerImageNodeID(n.ID); ok {
		output.Sets = output.Sets.Add(docker.ImageID, report.EmptyStringSet.Add(imageID))
	}

	return report.Nodes{output.ID: output}
}