Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten docker container and image IDs in the details panel. #930

Merged
merged 1 commit into from
Feb 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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