Merge pull request #74715 from andyzhangx/acr-public-access

fix Azure Container Registry anonymous repo image pull error
pull/564/head
Kubernetes Prow Robot 2019-03-01 02:29:40 -08:00 committed by GitHub
commit a5ba825b1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -206,6 +206,13 @@ func (a *acrProvider) Provide() credentialprovider.DockerConfig {
cfg[url] = *cred
}
}
// add ACR anonymous repo support: use empty username and password for anonymous access
cfg["*.azurecr.*"] = credentialprovider.DockerConfigEntry{
Username: "",
Password: "",
Email: dummyRegistryEmail,
}
return cfg
}

View File

@ -76,14 +76,14 @@ func Test(t *testing.T) {
creds := provider.Provide()
if len(creds) != len(result) {
t.Errorf("Unexpected list: %v, expected length %d", creds, len(result))
if len(creds) != len(result)+1 {
t.Errorf("Unexpected list: %v, expected length %d", creds, len(result)+1)
}
for _, cred := range creds {
if cred.Username != "foo" {
if cred.Username != "" && cred.Username != "foo" {
t.Errorf("expected 'foo' for username, saw: %v", cred.Username)
}
if cred.Password != "bar" {
if cred.Password != "" && cred.Password != "bar" {
t.Errorf("expected 'bar' for password, saw: %v", cred.Username)
}
}