From 3a1a580cfe84a7e689490ae9abaeb99bb5a632f0 Mon Sep 17 00:00:00 2001 From: Jerome Quere Date: Mon, 1 Jul 2019 17:39:55 +0200 Subject: [PATCH] test: add support for new config system in testAccPreCheck (#191) --- scaleway/provider_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scaleway/provider_test.go b/scaleway/provider_test.go index a0907f476c..4361a58505 100644 --- a/scaleway/provider_test.go +++ b/scaleway/provider_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" homedir "github.com/mitchellh/go-homedir" + "github.com/scaleway/scaleway-sdk-go/scwconfig" ) var testAccProviders map[string]terraform.ResourceProvider @@ -38,6 +39,17 @@ func TestProvider_impl(t *testing.T) { } func testAccPreCheck(t *testing.T) { + + // Handle new config system first + config, err := scwconfig.Load() + if err == nil { + _, hasAccessKey := config.GetAccessKey() + _, hasSecretKey := config.GetSecretKey() + if hasAccessKey && hasSecretKey { + return + } + } + if v := os.Getenv("SCALEWAY_ORGANIZATION"); v == "" { if path, err := homedir.Expand("~/.scwrc"); err == nil { scwAPIKey, scwOrganization, err := readDeprecatedScalewayConfig(path)