From f41675d234bb8212457ea04eae5d47dc3606bf6b Mon Sep 17 00:00:00 2001 From: Nishchay Date: Wed, 28 Aug 2019 09:07:33 -0700 Subject: [PATCH] fix: support empty auth config for anonymous registry - empty username means caller wants to use no credentials, typically for anonymous registry - Fixes https://github.com/containerd/cri/issues/1249 Signed-off-by: Nishchay Kumar --- pkg/server/image_pull.go | 3 ++- pkg/server/image_pull_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/server/image_pull.go b/pkg/server/image_pull.go index daa388481..942dcbeea 100644 --- a/pkg/server/image_pull.go +++ b/pkg/server/image_pull.go @@ -187,7 +187,8 @@ func ParseAuth(auth *runtime.AuthConfig, host string) (string, string, error) { return user, strings.Trim(passwd, "\x00"), nil } // TODO(random-liu): Support RegistryToken. - return "", "", errors.New("invalid auth config") + // An empty auth config is valid for anonymous registry + return "", "", nil } // createImageReference creates image reference inside containerd image store. diff --git a/pkg/server/image_pull_test.go b/pkg/server/image_pull_test.go index 91908c731..3a6377ca0 100644 --- a/pkg/server/image_pull_test.go +++ b/pkg/server/image_pull_test.go @@ -42,9 +42,9 @@ func TestParseAuth(t *testing.T) { expectErr bool }{ "should not return error if auth config is nil": {}, - "should return error if no supported auth is provided": { + "should not return error if empty auth is provided for access to anonymous registry": { auth: &runtime.AuthConfig{}, - expectErr: true, + expectErr: false, }, "should support identity token": { auth: &runtime.AuthConfig{IdentityToken: "abcd"},