Merge pull request #40142 from colemickens/colemickens-acr-login-server

Automatic merge from submit-queue (batch tested with PRs 37055, 40142)

azure: azure container registry: fix login server

**What this PR does / why we need it**:

Fixes the Azure Container Registry integration

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
n/a

**Special notes for your reviewer**:

Before this change, if I created an ACR with name `colemicktest`, then the login server would be `colemicktest-microsoft.azurecr.io`. This code was concating to form `colemicktest.azurecr.io` which does not work.

The fix is to reach into RegistryProperties and read out the login server domain name directly.

Also, this should eliminate that existed when ACR gets to sovereign clouds.

**Release note**:

```release-note
azure: fix Azure Container Registry integration
```
pull/6/head
Kubernetes Submit Queue 2017-01-25 00:40:02 -08:00 committed by GitHub
commit d62fca231e
2 changed files with 17 additions and 4 deletions

View File

@ -17,7 +17,6 @@ limitations under the License.
package azure
import (
"fmt"
"io/ioutil"
"time"
@ -133,12 +132,17 @@ func (a *acrProvider) Provide() credentialprovider.DockerConfig {
return cfg
}
for ix := range *res.Value {
// TODO: I don't think this will work for national clouds
cfg[fmt.Sprintf("%s.azurecr.io", *(*res.Value)[ix].Name)] = entry
loginServer := getLoginServer((*res.Value)[ix])
glog.V(4).Infof("Adding Azure Container Registry docker credential for %s", loginServer)
cfg[loginServer] = entry
}
return cfg
}
func getLoginServer(registry containerregistry.Registry) string {
return *(*registry.RegistryProperties).LoginServer
}
func (a *acrProvider) LazyProvide() *credentialprovider.DockerConfigEntry {
return nil
}

View File

@ -41,12 +41,21 @@ func Test(t *testing.T) {
Value: &[]containerregistry.Registry{
{
Name: to.StringPtr("foo"),
RegistryProperties: &containerregistry.RegistryProperties{
LoginServer: to.StringPtr("foo-microsoft.azurecr.io"),
},
},
{
Name: to.StringPtr("bar"),
RegistryProperties: &containerregistry.RegistryProperties{
LoginServer: to.StringPtr("bar-microsoft.azurecr.io"),
},
},
{
Name: to.StringPtr("baz"),
RegistryProperties: &containerregistry.RegistryProperties{
LoginServer: to.StringPtr("baz-microsoft.azurecr.io"),
},
},
},
}
@ -73,7 +82,7 @@ func Test(t *testing.T) {
}
}
for _, val := range *result.Value {
registryName := *val.Name + ".azurecr.io"
registryName := getLoginServer(val)
if _, found := creds[registryName]; !found {
t.Errorf("Missing expected registry: %s", registryName)
}