Merge pull request #848 from runcom/panic-img
pkg: storage: fix panic when no image names
This commit is contained in:
commit
a81e90a9c9
1 changed files with 12 additions and 8 deletions
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue