@@ -43,9 +43,9 @@ func fetchManifest(ctx context.Context, repo distribution.Repository, ref refere
4343 }
4444 return imageManifest , nil
4545 case * manifestlist.DeserializedManifestList :
46- return types.ImageManifest {}, errors .Errorf ( "%s is a manifest list" , ref )
46+ return types.ImageManifest {}, errors .Wrapf ( types . ErrManifestNotFound , "%q is a manifest list" , ref )
4747 }
48- return types.ImageManifest {}, errors .Errorf ( "%s is not a manifest " , ref )
48+ return types.ImageManifest {}, errors .Wrapf ( types . ErrUnknownType , "%q does not exist " , ref )
4949}
5050
5151func fetchList (ctx context.Context , repo distribution.Repository , ref reference.Named ) ([]types.ImageManifest , error ) {
@@ -55,14 +55,16 @@ func fetchList(ctx context.Context, repo distribution.Repository, ref reference.
5555 }
5656
5757 switch v := manifest .(type ) {
58+ case * schema2.DeserializedManifest , * ocischema.DeserializedManifest :
59+ return nil , errors .Wrapf (types .ErrManifestNotFound , "%q is not a manifest list" , ref )
5860 case * manifestlist.DeserializedManifestList :
5961 imageManifests , err := pullManifestList (ctx , ref , repo , * v )
6062 if err != nil {
6163 return nil , err
6264 }
6365 return imageManifests , nil
6466 default :
65- return nil , errors . Errorf ( "unsupported manifest format: %v" , v )
67+ return nil , types . ErrUnknownType
6668 }
6769}
6870
@@ -74,7 +76,7 @@ func getManifest(ctx context.Context, repo distribution.Repository, ref referenc
7476
7577 dgst , opts , err := getManifestOptionsFromReference (ref )
7678 if err != nil {
77- return nil , errors .Errorf ( "image manifest for %q does not exist" , ref )
79+ return nil , errors .Wrapf ( types . ErrManifestNotFound , " %q does not exist" , ref )
7880 }
7981 return manSvc .Get (ctx , dgst , opts ... )
8082}
@@ -195,7 +197,7 @@ func pullManifestList(ctx context.Context, ref reference.Named, repo distributio
195197 case * ocischema.DeserializedManifest :
196198 imageManifest , err = pullManifestOCISchema (ctx , manifestRef , repo , * v )
197199 default :
198- err = errors . Errorf ( "unsupported manifest type: %T" , manifest )
200+ err = types . ErrUnknownType
199201 }
200202 if err != nil {
201203 return nil , err
@@ -287,7 +289,7 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
287289 return nil
288290 }
289291 }
290- return newNotFoundError ( namedRef . String () )
292+ return errors . Wrapf ( types . ErrManifestNotFound , "%q does not exist" , namedRef )
291293}
292294
293295// allEndpoints returns a list of endpoints ordered by priority (v2, https, v1).
@@ -310,18 +312,3 @@ func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoi
310312 logrus .Debugf ("endpoints for %s: %v" , namedRef , endpoints )
311313 return endpoints , err
312314}
313-
314- func newNotFoundError (ref string ) * notFoundError {
315- return & notFoundError {err : errors .New ("no such manifest: " + ref )}
316- }
317-
318- type notFoundError struct {
319- err error
320- }
321-
322- func (n * notFoundError ) Error () string {
323- return n .err .Error ()
324- }
325-
326- // NotFound satisfies interface github.com/docker/docker/errdefs.ErrNotFound
327- func (n * notFoundError ) NotFound () {}
0 commit comments