Skip to content

Commit

Permalink
fix the access type setting null exception in resource update (#902)
Browse files Browse the repository at this point in the history
- make access_level and access_type schema computed true
- use d.GetOk() instead of d.Get() and empty check
  • Loading branch information
Lance52259 authored Feb 5, 2021
1 parent d5ee6fe commit f9f5727
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions huaweicloud/resource_huaweicloud_sfs_file_system_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f9f5727

Please sign in to comment.