Merge pull request #2410 from tonistiigi/mlist-error

images: provide better error for manifest list match error
This commit is contained in:
Phil Estes 2018-06-20 23:03:37 -04:00 committed by GitHub
commit 7ff2748f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,11 +129,14 @@ func (image *Image) Size(ctx context.Context, provider content.Provider, platfor
// this direction because this abstraction is not needed.` // this direction because this abstraction is not needed.`
func Manifest(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform string) (ocispec.Manifest, error) { func Manifest(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform string) (ocispec.Manifest, error) {
var ( var (
matcher platforms.Matcher matcher platforms.Matcher
m *ocispec.Manifest m *ocispec.Manifest
p ocispec.Platform
wasIndex bool
) )
if platform != "" { if platform != "" {
p, err := platforms.Parse(platform) var err error
p, err = platforms.Parse(platform)
if err != nil { if err != nil {
return ocispec.Manifest{}, err return ocispec.Manifest{}, err
} }
@ -201,6 +204,8 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc
} }
} }
wasIndex = true
return descs, nil return descs, nil
} }
@ -210,7 +215,11 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc
} }
if m == nil { 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 return *m, nil