Ejemplo n.º 1
0
func containerImageNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
	imageName, ok := n.Latest.Lookup(docker.ImageName)
	if !ok {
		return NodeSummary{}, false
	}

	imageNameWithoutVersion := docker.ImageNameWithoutVersion(imageName)
	base.Label = imageNameWithoutVersion
	base.Rank = imageNameWithoutVersion
	base.Stack = true

	if base.Label == ImageNameNone {
		base.Label, _ = n.Latest.Lookup(docker.ImageID)
		if len(base.Label) > 12 {
			base.Label = base.Label[:12]
		}
	}

	if c, ok := n.Counters.Lookup(report.Container); ok {
		if c == 1 {
			base.LabelMinor = fmt.Sprintf("%d container", c)
		} else {
			base.LabelMinor = fmt.Sprintf("%d containers", c)
		}
	}
	return base, true
}
Ejemplo n.º 2
0
func containerImageParent(n report.Node) Parent {
	imageName, _ := n.Latest.Lookup(docker.ImageName)
	return Parent{
		ID:         n.ID,
		Label:      docker.ImageNameWithoutVersion(imageName),
		TopologyID: "containers-by-image",
	}
}
Ejemplo n.º 3
0
func containerNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
	base.Label = getRenderableContainerName(n)
	base.LabelMinor = report.ExtractHostID(n)

	if imageName, ok := n.Latest.Lookup(docker.ImageName); ok {
		base.Rank = docker.ImageNameWithoutVersion(imageName)
	}

	return base, true
}
Ejemplo n.º 4
0
func isPauseContainer(n report.Node, rpt report.Report) bool {
	containerImageIDs, ok := n.Parents.Lookup(report.ContainerImage)
	if !ok {
		return false
	}
	for _, imageNodeID := range containerImageIDs {
		imageNode, ok := rpt.ContainerImage.Nodes[imageNodeID]
		if !ok {
			continue
		}
		imageName, ok := imageNode.Latest.Lookup(docker.ImageName)
		if !ok {
			continue
		}
		if docker.ImageNameWithoutVersion(imageName) == "google_containers/pause" {
			return true
		}
	}
	return false
}