From bd6d7c693146e6fe7444350c4cb6915e15d1af26 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Thu, 11 Feb 2016 10:30:56 -0800 Subject: [PATCH] Fall back to V1 when there are no basic auth credentials This makes the behavior consistent with having incorrect credentials. Signed-off-by: Aaron Lehmann Upstream-commit: 7b81bc147cf75cb32697e8fdf88e05ae879cb879 Component: engine --- components/engine/distribution/pull_v2.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/engine/distribution/pull_v2.go b/components/engine/distribution/pull_v2.go index 0e04c46c32..00cf7a5f41 100644 --- a/components/engine/distribution/pull_v2.go +++ b/components/engine/distribution/pull_v2.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/ioutil" + "net/url" "os" "runtime" @@ -17,6 +18,7 @@ import ( "github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/registry/api/errcode" "github.com/docker/distribution/registry/client" + "github.com/docker/distribution/registry/client/auth" "github.com/docker/distribution/registry/client/transport" "github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/xfer" @@ -710,6 +712,10 @@ func allowV1Fallback(err error) error { if registry.ShouldV2Fallback(v) { return fallbackError{err: err, confirmedV2: false} } + case *url.Error: + if v.Err == auth.ErrNoBasicAuthCredentials { + return fallbackError{err: err, confirmedV2: false} + } } return err