mirror of https://github.com/k3s-io/k3s
swap the return statements
parent
45ae5bf1e5
commit
6a1b31323e
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue