From 0836b39d9540d91d42c8184595611d9bee0153dd Mon Sep 17 00:00:00 2001 From: zhangguanzhang Date: Wed, 19 Aug 2020 09:45:02 +0800 Subject: [PATCH] Define an error to allow an external reference Signed-off-by: zhangguanzhang --- oci/layout/oci_transport.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oci/layout/oci_transport.go b/oci/layout/oci_transport.go index a99b631584..776c6e2fe1 100644 --- a/oci/layout/oci_transport.go +++ b/oci/layout/oci_transport.go @@ -30,6 +30,9 @@ var ( // ErrMoreThanOneImage is an error returned when the manifest includes // more than one image and the user should choose which one to use. ErrMoreThanOneImage = errors.New("more than one image in oci, choose an image") + + // ErrNotFoundDescriptor is an error when the reference cannot found in the manifests + ErrNotFoundDescriptor = errors.New("no descriptor found for the reference") ) type ociTransport struct{} @@ -209,7 +212,7 @@ func (ref ociReference) getManifestDescriptor() (imgspecv1.Descriptor, error) { } } if d == nil { - return imgspecv1.Descriptor{}, fmt.Errorf("no descriptor found for reference %q", ref.image) + return imgspecv1.Descriptor{}, errors.Wrap(ErrNotFoundDescriptor, ref.image) } return *d, nil }