pkg: storage: fix panic when no image names
@@ -99,6 +99,8 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s
return nil, err
}
for _, image := range images {
+ var size *uint64
+ if len(image.Names) != 0 {
ref, err := svc.getRef(image.Names[0])
if err != nil {
return nil, err
@@ -107,10 +109,12 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s
if err != nil {
return nil, err
}
+ size = imageSize(img)
+ }
results = append(results, ImageResult{
ID: image.ID,
Names: image.Names,
- Size: imageSize(img),
+ Size: size,
})
}
}
