c8d/list: Fix premature Images return

52a80b40e2 extracted the `imageSummary`
function but introduced a bug causing the whole caller function to
return if the image should be skipped.

`imageSummary` returns a nil error and nil image when the image doesn't
have any platform or all its platforms are not available locally.
In this case that particular image should be skipped, instead of failing
the whole image list operation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2024-03-15 13:52:24 +01:00
parent a9bca45e92
commit f512dba037
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -154,9 +154,13 @@ func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions)
for _, img := range uniqueImages {
image, allChainsIDs, err := i.imageSummary(ctx, img, platformMatcher, opts, tagsByDigest)
if err != nil || image == nil {
if err != nil {
return nil, err
}
// No error, but image should be skipped.
if image == nil {
continue
}
summaries = append(summaries, image)