Skip to content

Commit ca45b92

Browse files
W3QKR2Tdmcgowan
authored andcommitted
Add ErrUnexpectedStatus to resolver
Signed-off-by: Fabian Hoffmann <[email protected]> (cherry picked from commit b90c466) Signed-off-by: Derek McGowan <[email protected]>
1 parent 77c0175 commit ca45b92

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
@@ -34,6 +34,7 @@ import (
3434
"github.com/containerd/containerd/reference"
3535
"github.com/containerd/containerd/remotes"
3636
"github.com/containerd/containerd/remotes/docker/schema1"
37+
remoteerrors "github.com/containerd/containerd/remotes/errors"
3738
"github.com/containerd/containerd/version"
3839
digest "github.com/opencontainers/go-digest"
3940
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -308,11 +309,11 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp
308309
if resp.StatusCode > 399 {
309310
// Set firstErr when encountering the first non-404 status code.
310311
if firstErr == nil {
311-
firstErr = fmt.Errorf("pulling from host %s failed with status code %v: %v", host.Host, u, resp.Status)
312+
firstErr = remoteerrors.NewUnexpectedStatusErr(resp)
312313
}
313314
continue // try another host
314315
}
315-
return "", ocispec.Descriptor{}, fmt.Errorf("pulling from host %s failed with unexpected status code %v: %v", host.Host, u, resp.Status)
316+
return "", ocispec.Descriptor{}, remoteerrors.NewUnexpectedStatusErr(resp)
316317
}
317318
size := resp.ContentLength
318319
contentType := getManifestMediaType(resp)

0 commit comments

Comments
 (0)