provider/scaleway: fix provider configuration (#11234)

properly fetch configuration from env - leftover from #10874
This commit is contained in:
Raphael Randschau 2017-01-17 13:50:10 +01:00 committed by Paul Stack
parent b054e627fe
commit 8183d4667a
2 changed files with 10 additions and 6 deletions

View File

@ -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{

View File

@ -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")
}
}