diff --git a/setup.go b/setup.go index 83b5a2b..4098768 100644 --- a/setup.go +++ b/setup.go @@ -169,10 +169,18 @@ func setup(c *caddy.Controller) error { // Keep this environment variable name consistent across all our integrations (e.g. SDKs, Terraform provider). accessToken = os.Getenv("DNSIMPLE_TOKEN") } + // Still blank, return error + if accessToken == "" { + return plugin.Error("dnsimple", c.Err("access token must be provided via the Corefile or DNSIMPLE_TOKEN environment variable")) + } if opts.accountId == "" { opts.accountId = os.Getenv("DNSIMPLE_ACCOUNT_ID") } + // Still blank, return error + if opts.accountId == "" { + return plugin.Error("dnsimple", c.Err("account ID must be provided via the Corefile or DNSIMPLE_TOKEN environment variable")) + } if baseUrl == "" { // Default to production diff --git a/setup_test.go b/setup_test.go index e451eb0..e78d2ac 100644 --- a/setup_test.go +++ b/setup_test.go @@ -9,6 +9,9 @@ import ( ) func TestSetupDNSimple(t *testing.T) { + t.Setenv("DNSIMPLE_TOKEN", "token") + t.Setenv("DNSIMPLE_ACCOUNT_ID", "12345") + fakeClient := new(fakeDNSimpleClient) newDnsimpleService = func(ctx context.Context, options Options, accessToken, baseUrl string) (dnsimpleService, error) { return fakeClient, nil