mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Merge pull request #1161 from weaveworks/1058-sha256-image-ids
strip sha256: from docker image ids
This commit is contained in:
@@ -123,7 +123,7 @@ func (c *container) ID() string {
|
||||
}
|
||||
|
||||
func (c *container) Image() string {
|
||||
return c.container.Image
|
||||
return trimImageID(c.container.Image)
|
||||
}
|
||||
|
||||
func (c *container) PID() int {
|
||||
@@ -340,7 +340,7 @@ func (c *container) GetNode(hostID string, localAddrs []net.IP) report.Node {
|
||||
ContainerName: strings.TrimPrefix(c.container.Name, "/"),
|
||||
ContainerCreated: c.container.Created.Format(time.RFC822),
|
||||
ContainerCommand: c.container.Path + " " + strings.Join(c.container.Args, " "),
|
||||
ImageID: c.container.Image,
|
||||
ImageID: c.Image(),
|
||||
ContainerHostname: c.Hostname(),
|
||||
ContainerState: state,
|
||||
}).WithSets(report.EmptySets.
|
||||
@@ -350,7 +350,7 @@ func (c *container) GetNode(hostID string, localAddrs []net.IP) report.Node {
|
||||
).WithMetrics(
|
||||
c.metrics(),
|
||||
).WithParents(report.EmptySets.
|
||||
Add(report.ContainerImage, report.MakeStringSet(report.MakeContainerImageNodeID(c.container.Image))),
|
||||
Add(report.ContainerImage, report.MakeStringSet(report.MakeContainerImageNodeID(c.Image()))),
|
||||
)
|
||||
|
||||
if c.container.State.Paused {
|
||||
|
||||
@@ -2,6 +2,7 @@ package docker
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
docker_client "github.com/fsouza/go-dockerclient"
|
||||
@@ -119,8 +120,9 @@ func (r *Reporter) containerImageTopology() report.Topology {
|
||||
result := report.MakeTopology()
|
||||
|
||||
r.registry.WalkImages(func(image *docker_client.APIImages) {
|
||||
imageID := trimImageID(image.ID)
|
||||
node := report.MakeNodeWith(map[string]string{
|
||||
ImageID: image.ID,
|
||||
ImageID: imageID,
|
||||
})
|
||||
node = AddLabels(node, image.Labels)
|
||||
|
||||
@@ -128,9 +130,15 @@ func (r *Reporter) containerImageTopology() report.Topology {
|
||||
node = node.WithLatests(map[string]string{ImageName: image.RepoTags[0]})
|
||||
}
|
||||
|
||||
nodeID := report.MakeContainerImageNodeID(image.ID)
|
||||
nodeID := report.MakeContainerImageNodeID(imageID)
|
||||
result.AddNode(nodeID, node)
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Docker sometimes prefixes ids with a "type" annotation, but it renders a bit
|
||||
// ugly and isn't necessary, so we should strip it off
|
||||
func trimImageID(id string) string {
|
||||
return strings.TrimPrefix(id, "sha256:")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user