From 8183d4667a374c8fdef29d16421fa2888f90f90b Mon Sep 17 00:00:00 2001 From: Raphael Randschau Date: Tue, 17 Jan 2017 13:50:10 +0100 Subject: [PATCH] provider/scaleway: fix provider configuration (#11234) properly fetch configuration from env - leftover from #10874 --- builtin/providers/scaleway/provider.go | 12 +++++++----- builtin/providers/scaleway/provider_test.go | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/builtin/providers/scaleway/provider.go b/builtin/providers/scaleway/provider.go index 8ab936efa..c05d6e977 100644 --- a/builtin/providers/scaleway/provider.go +++ b/builtin/providers/scaleway/provider.go @@ -12,16 +12,18 @@ func Provider() terraform.ResourceProvider { Schema: map[string]*schema.Schema{ "access_key": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ACCESS_KEY", nil), Deprecated: "Use `token` instead.", Description: "The API key for Scaleway API operations.", }, - "token": &schema.Schema{ - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_TOKEN", nil), + Type: schema.TypeString, + Required: true, + DefaultFunc: schema.MultiEnvDefaultFunc([]string{ + "SCALEWAY_TOKEN", + "SCALEWAY_ACCESS_KEY", + }, nil), Description: "The API key for Scaleway API operations.", }, "organization": &schema.Schema{ diff --git a/builtin/providers/scaleway/provider_test.go b/builtin/providers/scaleway/provider_test.go index d31d60b54..6575ef8fd 100644 --- a/builtin/providers/scaleway/provider_test.go +++ b/builtin/providers/scaleway/provider_test.go @@ -32,7 +32,9 @@ func testAccPreCheck(t *testing.T) { if v := os.Getenv("SCALEWAY_ORGANIZATION"); v == "" { t.Fatal("SCALEWAY_ORGANIZATION must be set for acceptance tests") } - if v := os.Getenv("SCALEWAY_TOKEN"); v == "" { + tokenFromAccessKey := os.Getenv("SCALEWAY_ACCESS_KEY") + token := os.Getenv("SCALEWAY_TOKEN") + if token == "" && tokenFromAccessKey == "" { t.Fatal("SCALEWAY_TOKEN must be set for acceptance tests") } }