From ad34a85dada244c4e4a50d71963a90ea70736033 Mon Sep 17 00:00:00 2001 From: SALLEYRON Julien Date: Thu, 13 Sep 2018 16:15:26 +0200 Subject: [PATCH] refactor: rename Alibaba DNS env var. (#636) --- cli.go | 2 +- providers/dns/alidns/alidns.go | 8 ++++---- providers/dns/alidns/alidns_test.go | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cli.go b/cli.go index 20eb1dcb..2ff318ab 100644 --- a/cli.go +++ b/cli.go @@ -203,7 +203,7 @@ Here is an example bash command using the CloudFlare DNS provider: fmt.Fprintln(w, "Valid providers and their associated credential environment variables:") fmt.Fprintln(w) fmt.Fprintln(w, "\tacme-dns:\tACME_DNS_API_BASE, ACME_DNS_STORAGE_PATH") - fmt.Fprintln(w, "\talidns:\tALIDNS_API_KEY, ALIDNS_SECRET_KEY") + fmt.Fprintln(w, "\talidns:\tALICLOUD_ACCESS_KEY, ALICLOUD_SECRET_KEY") fmt.Fprintln(w, "\tazure:\tAZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID, AZURE_RESOURCE_GROUP") fmt.Fprintln(w, "\tauroradns:\tAURORA_USER_ID, AURORA_KEY, AURORA_ENDPOINT") fmt.Fprintln(w, "\tbluecat:\tBLUECAT_SERVER_URL, BLUECAT_USER_NAME, BLUECAT_PASSWORD, BLUECAT_CONFIG_NAME, BLUECAT_DNS_VIEW") diff --git a/providers/dns/alidns/alidns.go b/providers/dns/alidns/alidns.go index 344c0369..13fd853a 100644 --- a/providers/dns/alidns/alidns.go +++ b/providers/dns/alidns/alidns.go @@ -21,16 +21,16 @@ type DNSProvider struct { } // NewDNSProvider returns a DNSProvider instance configured for Alibaba Cloud DNS. -// Credentials must be passed in the environment variables: ALIDNS_API_KEY and ALIDNS_SECRET_KEY. +// Credentials must be passed in the environment variables: ALICLOUD_ACCESS_KEY and ALICLOUD_SECRET_KEY. func NewDNSProvider() (*DNSProvider, error) { - values, err := env.Get("ALIDNS_API_KEY", "ALIDNS_SECRET_KEY") + values, err := env.Get("ALICLOUD_ACCESS_KEY", "ALICLOUD_SECRET_KEY") if err != nil { return nil, fmt.Errorf("AliDNS: %v", err) } - regionID := os.Getenv("ALIDNS_REGION_ID") + regionID := os.Getenv("ALICLOUD_REGION_ID") - return NewDNSProviderCredentials(values["ALIDNS_API_KEY"], values["ALIDNS_SECRET_KEY"], regionID) + return NewDNSProviderCredentials(values["ALICLOUD_ACCESS_KEY"], values["ALICLOUD_SECRET_KEY"], regionID) } // NewDNSProviderCredentials uses the supplied credentials to return a DNSProvider instance configured for alidns. diff --git a/providers/dns/alidns/alidns_test.go b/providers/dns/alidns/alidns_test.go index 91bd678f..2d201310 100644 --- a/providers/dns/alidns/alidns_test.go +++ b/providers/dns/alidns/alidns_test.go @@ -16,8 +16,8 @@ var ( ) func init() { - alidnsAPIKey = os.Getenv("ALIDNS_API_KEY") - alidnsSecretKey = os.Getenv("ALIDNS_SECRET_KEY") + alidnsAPIKey = os.Getenv("ALICLOUD_ACCESS_KEY") + alidnsSecretKey = os.Getenv("ALICLOUD_SECRET_KEY") alidnsDomain = os.Getenv("ALIDNS_DOMAIN") if len(alidnsAPIKey) > 0 && len(alidnsSecretKey) > 0 && len(alidnsDomain) > 0 { @@ -26,14 +26,14 @@ func init() { } func restoreEnv() { - os.Setenv("ALIDNS_API_KEY", alidnsAPIKey) - os.Setenv("ALIDNS_SECRET_KEY", alidnsSecretKey) + os.Setenv("ALICLOUD_ACCESS_KEY", alidnsAPIKey) + os.Setenv("ALICLOUD_SECRET_KEY", alidnsSecretKey) } func TestNewDNSProviderValid(t *testing.T) { defer restoreEnv() - os.Setenv("ALIDNS_API_KEY", "") - os.Setenv("ALIDNS_SECRET_KEY", "") + os.Setenv("ALICLOUD_ACCESS_KEY", "") + os.Setenv("ALICLOUD_SECRET_KEY", "") _, err := NewDNSProviderCredentials("123", "123", "") assert.NoError(t, err) @@ -41,8 +41,8 @@ func TestNewDNSProviderValid(t *testing.T) { func TestNewDNSProviderValidEnv(t *testing.T) { defer restoreEnv() - os.Setenv("ALIDNS_API_KEY", "123") - os.Setenv("ALIDNS_SECRET_KEY", "123") + os.Setenv("ALICLOUD_ACCESS_KEY", "123") + os.Setenv("ALICLOUD_SECRET_KEY", "123") _, err := NewDNSProvider() assert.NoError(t, err) @@ -50,11 +50,11 @@ func TestNewDNSProviderValidEnv(t *testing.T) { func TestNewDNSProviderMissingCredErr(t *testing.T) { defer restoreEnv() - os.Setenv("CLOUDXNS_API_KEY", "") - os.Setenv("CLOUDXNS_SECRET_KEY", "") + os.Setenv("ALICLOUD_ACCESS_KEY", "") + os.Setenv("ALICLOUD_SECRET_KEY", "") _, err := NewDNSProvider() - assert.EqualError(t, err, "AliDNS: some credentials information are missing: ALIDNS_API_KEY,ALIDNS_SECRET_KEY") + assert.EqualError(t, err, "AliDNS: some credentials information are missing: ALICLOUD_ACCESS_KEY,ALICLOUD_SECRET_KEY") } func TestCloudXNSPresent(t *testing.T) {