Merge pull request #46662 from vvoland/c8d-pull-access-denied-msg-2

c8d/pull: Don't wrap `no basic auth` error
This commit is contained in:
Sebastiaan van Stijn 2023-10-30 12:43:41 +01:00 committed by GitHub
commit dcf7287d64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"strings"
"github.com/containerd/containerd"
cerrdefs "github.com/containerd/containerd/errdefs"
@ -124,6 +125,11 @@ func (i *ImageService) PullImage(ctx context.Context, ref reference.Named, platf
img, err := i.client.Pull(ctx, ref.String(), opts...)
if err != nil {
if errors.Is(err, docker.ErrInvalidAuthorization) {
// Match error returned by containerd.
// https://github.com/containerd/containerd/blob/v1.7.8/remotes/docker/authorizer.go#L189-L191
if strings.Contains(err.Error(), "no basic auth credentials") {
return err
}
return errdefs.NotFound(fmt.Errorf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(ref)))
}
return err