Skip to content

Commit

Permalink
Merge pull request #2410 from tonistiigi/mlist-error
Browse files Browse the repository at this point in the history
images: provide better error for manifest list match error
  • Loading branch information
estesp committed Jun 21, 2018
2 parents c1e1f3d + 53fe31d commit 7ff2748
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions images/image.go
Expand Up @@ -129,11 +129,14 @@ func (image *Image) Size(ctx context.Context, provider content.Provider, platfor
// this direction because this abstraction is not needed.`
func Manifest(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform string) (ocispec.Manifest, error) {
var (
matcher platforms.Matcher
m *ocispec.Manifest
matcher platforms.Matcher
m *ocispec.Manifest
p ocispec.Platform
wasIndex bool
)
if platform != "" {
p, err := platforms.Parse(platform)
var err error
p, err = platforms.Parse(platform)
if err != nil {
return ocispec.Manifest{}, err
}
Expand Down Expand Up @@ -201,6 +204,8 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc
}
}

wasIndex = true

return descs, nil

}
Expand All @@ -210,7 +215,11 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc
}

if m == nil {
return ocispec.Manifest{}, errors.Wrapf(errdefs.ErrNotFound, "manifest %v", image.Digest)
err := errors.Wrapf(errdefs.ErrNotFound, "manifest %v", image.Digest)
if wasIndex {
err = errors.Wrapf(errdefs.ErrNotFound, "no match for current platform %s in manifest %v", platforms.Format(p), image.Digest)
}
return ocispec.Manifest{}, err
}

return *m, nil
Expand Down

0 comments on commit 7ff2748

Please sign in to comment.