mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 03:01:11 +00:00
render sensible labels for images with little/no metadata
We fall back to image id when we cannot find a name. We extract the image id from the node id rather than the docker.ImageID latest map entry since that way we are guaranteed to get it.
This commit is contained in:
@@ -243,25 +243,24 @@ func containerNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
}
|
||||
|
||||
func containerImageNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
imageName, ok := n.Latest.Lookup(docker.ImageName)
|
||||
if !ok {
|
||||
return NodeSummary{}, false
|
||||
var (
|
||||
imageName, _ = n.Latest.Lookup(docker.ImageName)
|
||||
imageNameWithoutVersion = docker.ImageNameWithoutVersion(imageName)
|
||||
)
|
||||
switch {
|
||||
case imageNameWithoutVersion != "" && imageNameWithoutVersion != ImageNameNone:
|
||||
base.Label = imageNameWithoutVersion
|
||||
case imageName != "" && imageName != ImageNameNone:
|
||||
base.Label = imageName
|
||||
default:
|
||||
// The id can be an image id or an image name. Ideally we'd
|
||||
// truncate the former but not the latter, but short of
|
||||
// heuristic regexp match we cannot tell the difference.
|
||||
base.Label, _ = report.ParseContainerImageNodeID(n.ID)
|
||||
}
|
||||
|
||||
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]
|
||||
}
|
||||
}
|
||||
|
||||
base.LabelMinor = pluralize(n.Counters, report.Container, "container", "containers")
|
||||
|
||||
base.Rank = base.Label
|
||||
base.Stack = true
|
||||
return base, true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user