|
@@ -4,6 +4,7 @@ import (
|
|
"context"
|
|
"context"
|
|
"fmt"
|
|
"fmt"
|
|
"io"
|
|
"io"
|
|
|
|
+ "strings"
|
|
|
|
|
|
"github.com/containerd/containerd"
|
|
"github.com/containerd/containerd"
|
|
cerrdefs "github.com/containerd/containerd/errdefs"
|
|
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...)
|
|
img, err := i.client.Pull(ctx, ref.String(), opts...)
|
|
if err != nil {
|
|
if err != nil {
|
|
if errors.Is(err, docker.ErrInvalidAuthorization) {
|
|
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 errdefs.NotFound(fmt.Errorf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(ref)))
|
|
}
|
|
}
|
|
return err
|
|
return err
|