From d1adb0a543fb3ffdb83713cb6fd8acd590c84f73 Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Fri, 29 May 2020 11:45:14 +0800 Subject: [PATCH] Use region as tenant_name if not set (#330) This makes tenant_name default to region to make the provider configuration more clear. --- huaweicloud/provider.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/huaweicloud/provider.go b/huaweicloud/provider.go index a5f710e7eb..b0fcc06051 100644 --- a/huaweicloud/provider.go +++ b/huaweicloud/provider.go @@ -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), @@ -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),