swap the return statements

pull/6/head
Zeqing Zhang 2017-08-08 12:49:44 +08:00
parent 45ae5bf1e5
commit 6a1b31323e
1 changed files with 9 additions and 6 deletions

View File

@ -30,9 +30,10 @@ import (
"k8s.io/kubernetes/pkg/credentialprovider" "k8s.io/kubernetes/pkg/credentialprovider"
) )
const chinaRegionPrefix = "cn-" const awsChinaRegionPrefix = "cn-"
const registryURLTemplate = "*.dkr.ecr.%s.amazonaws.com" const awsStandardDNSSuffix = "amazon.com"
const chinaRegistryURLTemplate = "*.dkr.ecr.%s.amazonaws.com.cn" const awsChinaDNSSuffix = "amazonaws.com.cn"
const registryURLTemplate = "*.dkr.ecr.%s.%s"
// awsHandlerLogger is a handler that logs all AWS SDK requests // awsHandlerLogger is a handler that logs all AWS SDK requests
// Copied from pkg/cloudprovider/providers/aws/log_handler.go // Copied from pkg/cloudprovider/providers/aws/log_handler.go
@ -84,10 +85,12 @@ var _ credentialprovider.DockerConfigProvider = &ecrProvider{}
// registryURL has different suffix in AWS China region // registryURL has different suffix in AWS China region
func registryURL(region string) string { func registryURL(region string) string {
if strings.HasPrefix(region, chinaRegionPrefix) { dnsSuffix := awsStandardDNSSuffix
return fmt.Sprintf(registryURLTemplate, region) // deal with aws none standard regions
if strings.HasPrefix(region, awsChinaRegionPrefix) {
dnsSuffix = awsChinaDNSSuffix
} }
return fmt.Sprintf(chinaRegistryURLTemplate, region) return fmt.Sprintf(registryURLTemplate, region, dnsSuffix)
} }
// RegisterCredentialsProvider registers a credential provider for the specified region. // RegisterCredentialsProvider registers a credential provider for the specified region.