diff --git a/pkg/credentialprovider/azure_credentials.go b/pkg/credentialprovider/azure_credentials.go index 871bd941af..08d010f759 100644 --- a/pkg/credentialprovider/azure_credentials.go +++ b/pkg/credentialprovider/azure_credentials.go @@ -44,7 +44,7 @@ const ( var ( containerRegistryUrls = []string{"*.azurecr.io", "*.azurecr.cn", "*.azurecr.de", "*.azurecr.us"} - acrRE = regexp.MustCompile(`.*\.azurecr\.io|.*\.azurecr\.cn|.*\.azurecr\.de|.*\.azurecr\.us`) + acrRE = regexp.MustCompile(`^.+?\.(azurecr\.io|azurecr\.cn|azurecr\.de|azurecr\.us)`) ) // CredentialProvider is an interface implemented by the kubelet credential provider plugin to fetch diff --git a/pkg/credentialprovider/azure_credentials_test.go b/pkg/credentialprovider/azure_credentials_test.go index 940fb53b8e..7a705bc681 100644 --- a/pkg/credentialprovider/azure_credentials_test.go +++ b/pkg/credentialprovider/azure_credentials_test.go @@ -193,6 +193,10 @@ func TestParseACRLoginServerFromImage(t *testing.T) { image: "foo.azurecr.my.cloud/bar/image:version", expected: "foo.azurecr.my.cloud", }, + { + image: "foo.azurecr.us/foo.azurecr.io/bar/image:version", + expected: "foo.azurecr.us", + }, } for _, test := range tests { if loginServer := provider.parseACRLoginServerFromImage(test.image); loginServer != test.expected {