Skip to content

Commit b90c466

Browse files
author
W3QKR2T
committed
Add ErrUnexpectedStatus to resolver
Signed-off-by: Fabian Hoffmann <[email protected]>
1 parent ab2f7dc commit b90c466

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

remotes/docker/resolver.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/containerd/containerd/reference"
3333
"github.com/containerd/containerd/remotes"
3434
"github.com/containerd/containerd/remotes/docker/schema1"
35+
remoteerrors "github.com/containerd/containerd/remotes/errors"
3536
"github.com/containerd/containerd/version"
3637
digest "github.com/opencontainers/go-digest"
3738
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -297,11 +298,11 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
297298
if resp.StatusCode > 399 {
298299
// Set firstErr when encountering the first non-404 status code.
299300
if firstErr == nil {
300-
firstErr = fmt.Errorf("pulling from host %s failed with status code %v: %v", host.Host, u, resp.Status)
301+
firstErr = remoteerrors.NewUnexpectedStatusErr(resp)
301302
}
302303
continue // try another host
303304
}
304-
return "", ocispec.Descriptor{}, fmt.Errorf("pulling from host %s failed with unexpected status code %v: %v", host.Host, u, resp.Status)
305+
return "", ocispec.Descriptor{}, remoteerrors.NewUnexpectedStatusErr(resp)
305306
}
306307
size := resp.ContentLength
307308
contentType := getManifestMediaType(resp)

0 commit comments

Comments
 (0)