azure: acr fix login server

This commit is contained in:
Cole Mickens 2017-01-19 04:22:12 -08:00
parent 0144fae64f
commit 1c72f2b9de
2 changed files with 17 additions and 4 deletions

View File

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

View File

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