Skip to content

Commit

Permalink
feat(sfs): sfsTurbo resource support update name field (#3771)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglong3710 authored Nov 30, 2023
1 parent e1e7151 commit 31e4c61
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/resources/sfs_turbo.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ The following arguments are supported:
* `region` - (Optional, String, ForceNew) The region in which to create the SFS Turbo resource. If omitted, the
provider-level region will be used. Changing this creates a new SFS Turbo resource.

* `name` - (Required, String, ForceNew) Specifies the name of an SFS Turbo file system. The value contains 4 to 64
characters and must start with a letter. Changing this will create a new resource.
* `name` - (Required, String) Specifies the name of an SFS Turbo file system. The value contains 4 to 64
characters and must start with a letter.

* `size` - (Required, Int) Specifies the capacity of a sharing file system, in GB.
+ If `share_type` is set to **STANDARD** or **PERFORMANCE**, the value ranges from 500 to 32768, and ranges from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestAccSFSTurbo_basic(t *testing.T) {
Config: testAccSFSTurbo_update(rName),
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
resource.TestCheckResourceAttr(resourceName, "name", fmt.Sprintf("%s-update", rName)),
resource.TestCheckResourceAttr(resourceName, "size", "600"),
resource.TestCheckResourceAttr(resourceName, "status", "221"),
resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar_update"),
Expand Down Expand Up @@ -398,7 +399,7 @@ func testAccSFSTurbo_update(rName string) string {
data "huaweicloud_availability_zones" "test" {}
resource "huaweicloud_sfs_turbo" "test" {
name = "%s"
name = "%s-update"
size = 600
share_proto = "NFS"
vpc_id = huaweicloud_vpc.test.id
Expand Down
11 changes: 10 additions & 1 deletion huaweicloud/services/sfs/resource_huaweicloud_sfs_turbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func ResourceSFSTurbo() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(4, 64),
},
"size": {
Expand Down Expand Up @@ -521,6 +520,16 @@ func resourceSFSTurboUpdate(ctx context.Context, d *schema.ResourceData, meta in
}
}

if d.HasChange("name") {
updateNameOpts := shares.UpdateNameOpts{
Name: d.Get("name").(string),
}
err = shares.UpdateName(sfsClient, d.Id(), updateNameOpts).Err
if err != nil {
return diag.Errorf("error updating name of SFS Turbo: %s", err)
}
}

return resourceSFSTurboRead(ctx, d, meta)
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 31e4c61

Please sign in to comment.