Skip to content

Commit

Permalink
Use region as tenant_name if not set (#330)
Browse files Browse the repository at this point in the history
This makes tenant_name default to region to make the provider configuration more clear.
  • Loading branch information
niuzhenguo authored May 29, 2020
1 parent bc43cf5 commit d1adb0a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion huaweicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ func init() {
}

func configureProvider(d *schema.ResourceData, terraformVersion string) (interface{}, error) {
var tenant_name string
// Use region as tenant_name if it's not set
if v, ok := d.GetOk("tenant_name"); ok && v.(string) != "" {
tenant_name = v.(string)
} else {
tenant_name = d.Get("region").(string)
}

config := Config{
AccessKey: d.Get("access_key").(string),
SecretKey: d.Get("secret_key").(string),
Expand All @@ -394,7 +402,7 @@ func configureProvider(d *schema.ResourceData, terraformVersion string) (interfa
Region: d.Get("region").(string),
Token: d.Get("token").(string),
TenantID: d.Get("tenant_id").(string),
TenantName: d.Get("tenant_name").(string),
TenantName: tenant_name,
Username: d.Get("user_name").(string),
UserID: d.Get("user_id").(string),
AgencyName: d.Get("agency_name").(string),
Expand Down

0 comments on commit d1adb0a

Please sign in to comment.