Merge pull request #848 from runcom/panic-img

pkg: storage: fix panic when no image names
This commit is contained in:
Mrunal Patel 2017-09-06 17:31:34 -07:00 committed by GitHub
commit a81e90a9c9

View file

@ -99,18 +99,22 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s
return nil, err
}
for _, image := range images {
ref, err := svc.getRef(image.Names[0])
if err != nil {
return nil, err
}
img, err := ref.NewImage(systemContext)
if err != nil {
return nil, err
var size *uint64
if len(image.Names) != 0 {
ref, err := svc.getRef(image.Names[0])
if err != nil {
return nil, err
}
img, err := ref.NewImage(systemContext)
if err != nil {
return nil, err
}
size = imageSize(img)
}
results = append(results, ImageResult{
ID: image.ID,
Names: image.Names,
Size: imageSize(img),
Size: size,
})
}
}