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
This commit is contained in:
parent
c325a18420
commit
2afadeec66
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue