From eb3cd70497956b5bb6606ffc920f855556d22656 Mon Sep 17 00:00:00 2001 From: Lance52259 Date: Fri, 5 Feb 2021 10:10:49 +0800 Subject: [PATCH] fix: fix the access type setting null exception in resource update - make access_level and access_type schema computed true - use d.GetOk() instead of d.Get() and empty check --- huaweicloud/resource_huaweicloud_sfs_file_system_v2.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/huaweicloud/resource_huaweicloud_sfs_file_system_v2.go b/huaweicloud/resource_huaweicloud_sfs_file_system_v2.go index a5fca44e70..64a3efd578 100644 --- a/huaweicloud/resource_huaweicloud_sfs_file_system_v2.go +++ b/huaweicloud/resource_huaweicloud_sfs_file_system_v2.go @@ -72,10 +72,12 @@ func resourceSFSFileSystemV2() *schema.Resource { "access_level": { Type: schema.TypeString, Optional: true, + Computed: true, }, "access_type": { Type: schema.TypeString, Optional: true, + Computed: true, }, "access_to": { Type: schema.TypeString, @@ -336,9 +338,8 @@ func resourceSFSFileSystemV2Update(d *schema.ResourceData, meta interface{}) err } if d.HasChanges("access_to", "access_level", "access_type") { - ruleID := d.Get("share_access_id").(string) - if ruleID != "" { - deleteAccessOpts := shares.DeleteAccessOpts{AccessID: ruleID} + if ruleID, ok := d.GetOk("share_access_id"); ok { + deleteAccessOpts := shares.DeleteAccessOpts{AccessID: ruleID.(string)} deny := shares.DeleteAccess(sfsClient, d.Id(), deleteAccessOpts) if deny.Err != nil { return fmt.Errorf("Error changing access rules for share file : %s", deny.Err)