Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

AKS credentials for ACR #1694

Merged
merged 9 commits into from
Feb 12, 2019
4 changes: 2 additions & 2 deletions registry/azure.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ type azureCloudConfig struct {
// --azure-container-registry-config=/etc/kubernetes/azure.json, parsed by kubernetes/kubernetes' azure_credentials.go
// https://github.com/kubernetes/kubernetes/issues/58034 seeks to deprecate this kubelet command-line argument, possibly
// replacing it with managed identity for the Node VMs. See https://github.com/Azure/acr/blob/master/docs/AAD-OAuth.md
func GetAzureCloudConfigAADToken(host string) (creds, error) {
func getAzureCloudConfigAADToken(host string) (creds, error) {
jsonFile, err := ioutil.ReadFile(azureCloudConfigJsonFile)
if err != nil {
return creds{}, err
@@ -43,7 +43,7 @@ func GetAzureCloudConfigAADToken(host string) (creds, error) {
}

// List from https://github.com/kubernetes/kubernetes/blob/master/pkg/credentialprovider/azure/azure_credentials.go
func HostIsAzureContainerRegistry(host string) bool {
func hostIsAzureContainerRegistry(host string) bool {
for _, v := range []string{".azurecr.io", ".azurecr.cn", ".azurecr.de", ".azurecr.us"} {
if strings.HasSuffix(host, v) {
return true
2 changes: 1 addition & 1 deletion registry/azure_test.go
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ func Test_HostIsAzureContainerRegistry(t *testing.T) {
isACR: true,
},
} {
result := HostIsAzureContainerRegistry(v.host)
result := hostIsAzureContainerRegistry(v.host)
if result != v.isACR {
t.Fatalf("For test %q, expected isACR = %v but got %v", v.host, v.isACR, result)
}
4 changes: 2 additions & 2 deletions registry/credentials.go
Original file line number Diff line number Diff line change
@@ -145,8 +145,8 @@ func (cs Credentials) credsFor(host string) creds {
}
}

if HostIsAzureContainerRegistry(host) {
if cred, err := GetAzureCloudConfigAADToken(host); err == nil {
if hostIsAzureContainerRegistry(host) {
if cred, err := getAzureCloudConfigAADToken(host); err == nil {
return cred
}
}