images: provide better error for manifest list match error
@@ -131,9 +131,12 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc
var (
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
}
@@ -201,6 +204,8 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc
}
}
+ wasIndex = true
+
return descs, nil
}
@@ -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
