azure: acr fix login server
This commit is contained in:
parent
0144fae64f
commit
1c72f2b9de
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user