cloudflare dns01: consistent err prefix "while querying the Clouflare API..."

Signed-off-by: Maël Valais <mael@vls.dev>
Co-authored-by: Richard Wall <richard.wall@jetstack.io>
This commit is contained in:
Maël Valais 2021-07-05 16:34:20 +02:00
parent 26b074241a
commit d31768f61e
2 changed files with 6 additions and 6 deletions

View File

@ -62,10 +62,10 @@ func NewDNSProvider(dns01Nameservers []string) (*DNSProvider, error) {
// DNSProvider instance configured for cloudflare.
func NewDNSProviderCredentials(email, key, token string, dns01Nameservers []string) (*DNSProvider, error) {
if (email == "" && key != "") || (key == "" && token == "") {
return nil, fmt.Errorf("no cloudflare credential has been given (can be either an API key or an API token)")
return nil, fmt.Errorf("no Cloudflare credential has been given (can be either an API key or an API token)")
}
if key != "" && token != "" {
return nil, fmt.Errorf("the Cloudflare API key and API token cannot be both present simultanously")
return nil, fmt.Errorf("the Cloudflare API key and API token cannot be both present simultaneously")
}
// Cloudflare uses the X-Auth-Key header for its authentication.
// However, if the value of the X-Auth-Key header is invalid, the go
@ -287,9 +287,9 @@ func (c *DNSProvider) makeRequest(method, uri string, body io.Reader) (json.RawM
errStr += fmt.Sprintf("<- %d: %s", chainErr.Code, chainErr.Message)
}
}
return nil, fmt.Errorf("error from the Cloudflare API for %s %q \n%s", method, uri, errStr)
return nil, fmt.Errorf("while querying the Cloudflare API for %s %q \n%s", method, uri, errStr)
}
return nil, fmt.Errorf("error from the Cloudflare API for %s %q", method, uri)
return nil, fmt.Errorf("while querying the Cloudflare API for %s %q", method, uri)
}
return r.Result, nil

View File

@ -73,7 +73,7 @@ func TestNewDNSProviderKeyAndTokenProvided(t *testing.T) {
os.Setenv("CLOUDFLARE_EMAIL", "")
os.Setenv("CLOUDFLARE_API_KEY", "")
_, err := NewDNSProviderCredentials("123", "123", "123", util.RecursiveNameservers)
assert.EqualError(t, err, "CloudFlare key and token are both present")
assert.EqualError(t, err, "the Cloudflare API key and API token cannot be both present simultaneously")
restoreCloudFlareEnv()
}
@ -89,7 +89,7 @@ func TestNewDNSProviderMissingCredErr(t *testing.T) {
os.Setenv("CLOUDFLARE_EMAIL", "")
os.Setenv("CLOUDFLARE_API_KEY", "")
_, err := NewDNSProvider(util.RecursiveNameservers)
assert.EqualError(t, err, "CloudFlare credentials missing")
assert.EqualError(t, err, "no Cloudflare credential has been given (can be either an API key or an API token)")
restoreCloudFlareEnv()
}