Skip to content

Commit

Permalink
Update Azure Credentials Provider Regex to be non-greedy
Browse files Browse the repository at this point in the history
  • Loading branch information
jsedlak-microsoft authored and k8s-infra-cherrypick-robot committed Apr 7, 2024
1 parent c6623bb commit d822519
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/credentialprovider/azure_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/credentialprovider/azure_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d822519

Please sign in to comment.