Skip to content

Commit

Permalink
Shorten docker container and image IDs in the details panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwilkie committed Feb 5, 2016
1 parent 00cd193 commit 6e7c743
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions render/detailed/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var (
ltst(process.Threads),
)
containerNodeMetadata = renderMetadata(
ltst(docker.ContainerID),
ltst(docker.ImageID),
trnc(docker.ContainerID, 12),
trnc(docker.ImageID, 12),
ltst(docker.ContainerState),
ltst(docker.ContainerUptime),
ltst(docker.ContainerRestartCount),
Expand All @@ -33,7 +33,7 @@ var (
ltst(overlay.WeaveDNSHostname),
)
containerImageNodeMetadata = renderMetadata(
ltst(docker.ImageID),
trnc(docker.ImageID, 12),
)
podNodeMetadata = renderMetadata(
ltst(kubernetes.PodID),
Expand Down Expand Up @@ -120,3 +120,15 @@ func ltst(id string) func(report.Node) []MetadataRow {
return nil
}
}

func trnc(id string, length int) func(report.Node) []MetadataRow {
return func(n report.Node) []MetadataRow {
if val, ok := n.Latest.Lookup(id); ok {
if len(val) > length {
val = val[:length]
}
return []MetadataRow{{ID: id, Value: val}}
}
return nil
}
}

0 comments on commit 6e7c743

Please sign in to comment.