From 2afadeec6696fefac468a49c8ba24b0bc275aa75 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Fri, 7 Sep 2018 10:51:51 +1200 Subject: Fix displaying size on size calculation error With this change if an error is raised when fetching the size of the image, the error string will be printed as the size (instead of panicing). In this particular case, the error string is "unable to determine size". This fixes bug #1405 Signed-off-by: Steve Baker Closes: #1423 Approved by: mheon --- cmd/podman/images.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/images.go b/cmd/podman/images.go index 4cf819f3c..f88ca32fd 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -284,8 +284,11 @@ func getImagesTemplateOutput(ctx context.Context, runtime *libpod.Runtime, image for repo, tags := range image.ReposToMap(img.Names()) { for _, tag := range tags { size, err := img.Size(ctx) + var sizeStr string if err != nil { - size = nil + sizeStr = err.Error() + } else { + sizeStr = units.HumanSizeWithPrecision(float64(*size), 3) } params := imagesTemplateParams{ Repository: repo, @@ -294,7 +297,7 @@ func getImagesTemplateOutput(ctx context.Context, runtime *libpod.Runtime, image Digest: img.Digest(), CreatedTime: createdTime, Created: units.HumanDuration(time.Since((createdTime))) + " ago", - Size: units.HumanSizeWithPrecision(float64(*size), 3), + Size: sizeStr, } imagesOutput = append(imagesOutput, params) } -- cgit v1.2.3-54-g00ecf