summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2018-09-07 10:51:51 +1200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-07 21:31:32 +0000
commit2afadeec6696fefac468a49c8ba24b0bc275aa75 (patch)
tree7c9a317c12f4db0b057225342dcb5ec57269ea4c /cmd/podman
parentc325a1842039eb7af1b6114c5f819ffe2d30bfe9 (diff)
downloadpodman-2afadeec6696fefac468a49c8ba24b0bc275aa75.tar.gz
podman-2afadeec6696fefac468a49c8ba24b0bc275aa75.tar.bz2
podman-2afadeec6696fefac468a49c8ba24b0bc275aa75.zip
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 <sbaker@redhat.com> Closes: #1423 Approved by: mheon
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/images.go7
1 files changed, 5 insertions, 2 deletions
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)
}