Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that environment variables are provided #24

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading