Skip to content

Commit

Permalink
Merge pull request #930 from weaveworks/924-short-ids
Browse files Browse the repository at this point in the history
Shorten docker container and image IDs in the details panel.
  • Loading branch information
paulbellamy committed Feb 8, 2016
2 parents 30dd97b + 107d306 commit bf3d92f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions render/detailed/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var (
Latest{ID: process.Threads},
}
containerNodeMetadata = []MetadataRowTemplate{
Latest{ID: docker.ContainerID},
Latest{ID: docker.ImageID},
Latest{ID: docker.ContainerID, Truncate: 12},
Latest{ID: docker.ImageID, Truncate: 12},
Latest{ID: docker.ContainerState},
Latest{ID: docker.ContainerUptime},
Latest{ID: docker.ContainerRestartCount},
Expand All @@ -35,7 +35,7 @@ var (
Latest{ID: overlay.WeaveDNSHostname},
}
containerImageNodeMetadata = []MetadataRowTemplate{
Latest{ID: docker.ImageID},
Latest{ID: docker.ImageID, Truncate: 12},
Counter{ID: render.ContainersKey},
}
podNodeMetadata = []MetadataRowTemplate{
Expand All @@ -59,12 +59,16 @@ type MetadataRowTemplate interface {

// Latest extracts some metadata rows from a node's Latest
type Latest struct {
ID string
ID string
Truncate int
}

// MetadataRows implements MetadataRowTemplate
func (l Latest) MetadataRows(n report.Node) []MetadataRow {
if val, ok := n.Latest.Lookup(l.ID); ok {
if l.Truncate > 0 && len(val) > l.Truncate {
val = val[:l.Truncate]
}
return []MetadataRow{{ID: l.ID, Value: val}}
}
return nil
Expand Down

0 comments on commit bf3d92f

Please sign in to comment.