From 107d3068d581a88d3df2010bd544fae300b85e19 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 5 Feb 2016 10:54:53 +0000 Subject: [PATCH] Shorten docker container and image IDs in the details panel. --- render/detailed/metadata.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/render/detailed/metadata.go b/render/detailed/metadata.go index 9a561de3f4..4643fb6302 100644 --- a/render/detailed/metadata.go +++ b/render/detailed/metadata.go @@ -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}, @@ -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{ @@ -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