From c62c2b907c98387e9732cc55003117e76d241133 Mon Sep 17 00:00:00 2001 From: Jason-Zhang Date: Mon, 4 Sep 2023 16:40:47 +0800 Subject: [PATCH] refactor(sfs-turbo): refer to huaweicloud and update the doc (#972) --- docs/resources/sfs_turbo.md | 88 ++--- .../resource_flexibleengine_sfs_turbo_test.go | 95 +++--- flexibleengine/provider.go | 2 +- .../resource_flexibleengine_sfs_turbo.go | 302 ------------------ go.mod | 2 +- 5 files changed, 108 insertions(+), 381 deletions(-) rename flexibleengine/{ => acceptance}/resource_flexibleengine_sfs_turbo_test.go (65%) delete mode 100644 flexibleengine/resource_flexibleengine_sfs_turbo.go diff --git a/docs/resources/sfs_turbo.md b/docs/resources/sfs_turbo.md index 4f7545b83..44fa2e1b9 100644 --- a/docs/resources/sfs_turbo.md +++ b/docs/resources/sfs_turbo.md @@ -11,33 +11,24 @@ Provides an Shared File System (SFS) Turbo resource. ## Example Usage ```hcl +variable "vpc_id" {} +variable "subnet_id" {} +variable "secgroup_id" {} variable "test_az" {} -resource "flexibleengine_vpc_v1" "example_vpc" { - name = "example-vpc" - cidr = "192.168.0.0/16" -} - -resource "flexibleengine_vpc_subnet_v1" "example_subnet" { - name = "example-vpc-subnet" - cidr = "192.168.0.0/24" - gateway_ip = "192.168.0.1" - vpc_id = flexibleengine_vpc_v1.example_vpc.id -} - -resource "flexibleengine_networking_secgroup_v2" "example_secgroup" { - name = "example-secgroup" - description = "My neutron security group" -} - -resource "flexibleengine_sfs_turbo" "sfs-turbo-1" { - name = "sfs-turbo-1" - size = 500 - share_proto = "NFS" - vpc_id = flexibleengine_vpc_v1.example_vpc.id - subnet_id = flexibleengine_vpc_subnet_v1.example_subnet.id - security_group_id = flexibleengine_networking_secgroup_v2.example_secgroup.id +resource "flexibleengine_sfs_turbo" "test" { + name = "sfs-turbo-1" + size = 500 + share_proto = "NFS" + vpc_id = var.vpc_id + subnet_id = var.subnet_id + security_group_id = var.secgroup_id availability_zone = var.test_az + + tags = { + foo = "bar" + key = "value" + } } ``` @@ -45,35 +36,44 @@ resource "flexibleengine_sfs_turbo" "sfs-turbo-1" { The following arguments are supported: -* `name` - (Required) Specifies the name of an SFS Turbo file system. The value contains 4 to 64 +* `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. -* `size` - (Required) Specifies the capacity of a common file system, in GB. The value ranges from 500 to 32768. +* `size` - (Required, Int) Specifies the capacity of a sharing file system, in GB. The value ranges from 500 to 32768. -* `share_proto` - (Optional) Specifies the protocol for sharing file systems. The valid value is NFS. - Changing this will create a new resource. + -> The file system capacity can only be expanded, not reduced. -* `share_type` - (Optional) Specifies the file system type. The valid values are STANDARD and PERFORMANCE. +* `share_proto` - (Optional, String, ForceNew) Specifies the protocol for sharing file systems. The valid value is NFS. Changing this will create a new resource. -* `availability_zone` - (Required) Specifies the availability zone where the file system is located. +* `share_type` - (Optional, String, ForceNew) Specifies the file system type. Changing this will create a new resource. + Valid values are **STANDARD** and **PERFORMANCE**. Defaults to **STANDARD**. + +* `availability_zone` - (Required, String, ForceNew) Specifies the availability zone where the file system is located. Changing this will create a new resource. -* `vpc_id` - (Required) Specifies the VPC ID. Changing this will create a new resource. +* `vpc_id` - (Required, String, ForceNew) Specifies the VPC ID. Changing this will create a new resource. -* `subnet_id` - (Required) Specifies the ID of the VPC Subnet. Changing this will create a new resource. +* `subnet_id` - (Required, String, ForceNew) Specifies the network ID of the subnet. Changing this will create a new + resource. -* `security_group_id` - (Required) Specifies the security group ID. Changing this will create a new resource. +* `security_group_id` - (Required, String, ForceNew) Specifies the security group ID. Changing this will create a new + resource. -* `crypt_key_id` - (Optional) Specifies the ID of a KMS key to encrypt the file system. - Changing this will create a new resource. +* `crypt_key_id` - (Optional, String, ForceNew) Specifies the ID of a KMS key to encrypt the file system. Changing this + will create a new resource. + +* `tags` - (Optional, Map) Specifies the key/value pairs to associate with the SFS Turbo. -> **NOTE:** - SFS Turbo will create two private IP addresses and one virtual IP address under the subnet you specified. - To ensure normal use, SFS Turbo will enable the inbound rules for ports *111*, *445*, *2049*, *2051*, *2052*, - and *20048* in the security group you specified. +SFS Turbo will create two private IP addresses and one virtual IP address under the subnet you specified. To ensure +normal use, SFS Turbo will enable the inbound rules for ports *111*, *445*, *2049*, *2051*, *2052*, and *20048* in the +security group you specified. -## Attributes Reference +## Attribute Reference In addition to all arguments above, the following attributes are exported: @@ -89,10 +89,18 @@ In addition to all arguments above, the following attributes are exported: * `available_capacity` - The available capacity of the SFS Turbo file system in the unit of GB. +## Timeouts + +This resource provides the following timeouts configuration options: + +* `create` - Default is 60 minutes. +* `update` - Default is 60 minutes. +* `delete` - Default is 10 minutes. + ## Import SFS Turbo can be imported using the `id`, e.g. -```shell +```bash terraform import flexibleengine_sfs_turbo 1e3d5306-24c9-4316-9185-70e9787d71ab ``` diff --git a/flexibleengine/resource_flexibleengine_sfs_turbo_test.go b/flexibleengine/acceptance/resource_flexibleengine_sfs_turbo_test.go similarity index 65% rename from flexibleengine/resource_flexibleengine_sfs_turbo_test.go rename to flexibleengine/acceptance/resource_flexibleengine_sfs_turbo_test.go index 5d2a0a781..6ebf4284c 100644 --- a/flexibleengine/resource_flexibleengine_sfs_turbo_test.go +++ b/flexibleengine/acceptance/resource_flexibleengine_sfs_turbo_test.go @@ -1,13 +1,16 @@ -package flexibleengine +package acceptance import ( "fmt" "testing" - "github.com/chnsz/golangsdk/openstack/sfs_turbo/v1/shares" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/chnsz/golangsdk/openstack/sfs_turbo/v1/shares" + + "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config" ) func TestAccSFSTurbo_basic(t *testing.T) { @@ -17,9 +20,9 @@ func TestAccSFSTurbo_basic(t *testing.T) { var turbo shares.Turbo resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckSFSTurboDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: TestAccProviderFactories, + CheckDestroy: testAccCheckSFSTurboDestroy, Steps: []resource.TestStep{ { Config: testAccSFSTurbo_basic(randSuffix), @@ -30,6 +33,8 @@ func TestAccSFSTurbo_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "share_type", "STANDARD"), resource.TestCheckResourceAttr(resourceName, "size", "500"), resource.TestCheckResourceAttr(resourceName, "status", "200"), + resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar"), + resource.TestCheckResourceAttr(resourceName, "tags.key", "value"), ), }, { @@ -41,8 +46,10 @@ func TestAccSFSTurbo_basic(t *testing.T) { Config: testAccSFSTurbo_update(randSuffix), Check: resource.ComposeTestCheckFunc( testAccCheckSFSTurboExists(resourceName, &turbo), - resource.TestCheckResourceAttr(resourceName, "size", "600"), - resource.TestCheckResourceAttr(resourceName, "status", "221"), + resource.TestCheckResourceAttr(resourceName, "size", "500"), + resource.TestCheckResourceAttr(resourceName, "status", "200"), + resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar_update"), + resource.TestCheckResourceAttr(resourceName, "tags.key", "value_update"), ), }, }, @@ -56,9 +63,9 @@ func TestAccSFSTurbo_crypt(t *testing.T) { var turbo shares.Turbo resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckSFSTurboDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: TestAccProviderFactories, + CheckDestroy: testAccCheckSFSTurboDestroy, Steps: []resource.TestStep{ { Config: testAccSFSTurbo_crypt(randSuffix), @@ -77,10 +84,10 @@ func TestAccSFSTurbo_crypt(t *testing.T) { } func testAccCheckSFSTurboDestroy(s *terraform.State) error { - config := testAccProvider.Meta().(*Config) + config := testAccProvider.Meta().(*config.Config) sfsClient, err := config.SfsV1Client(OS_REGION_NAME) if err != nil { - return fmt.Errorf("Error creating FlexibleEngine sfs turbo client: %s", err) + return fmt.Errorf("Error creating flexibleengine sfs turbo client: %s", err) } for _, rs := range s.RootModule().Resources { @@ -108,10 +115,10 @@ func testAccCheckSFSTurboExists(n string, share *shares.Turbo) resource.TestChec return fmt.Errorf("No ID is set") } - config := testAccProvider.Meta().(*Config) + config := testAccProvider.Meta().(*config.Config) sfsClient, err := config.SfsV1Client(OS_REGION_NAME) if err != nil { - return fmt.Errorf("Error creating FlexibleEngine sfs turbo client: %s", err) + return fmt.Errorf("Error creating flexibleengine sfs turbo client: %s", err) } found, err := shares.Get(sfsClient, rs.Primary.ID).Extract() @@ -152,52 +159,66 @@ resource "flexibleengine_networking_secgroup_v2" "secgroup" { func testAccSFSTurbo_basic(suffix string) string { return fmt.Sprintf(` %s +data "flexibleengine_availability_zones" "myaz" {} resource "flexibleengine_sfs_turbo" "sfs-turbo1" { - name = "sfs-turbo-acc-%s" - size = 500 - share_proto = "NFS" - vpc_id = flexibleengine_vpc_v1.test.id - subnet_id = flexibleengine_vpc_subnet_v1.test.id + name = "sfs-turbo-acc-%s" + size = 500 + share_proto = "NFS" + vpc_id = flexibleengine_vpc_v1.test.id + subnet_id = flexibleengine_vpc_subnet_v1.test.id security_group_id = flexibleengine_networking_secgroup_v2.secgroup.id - availability_zone = "%s" + availability_zone = data.flexibleengine_availability_zones.myaz.names[0] + + tags = { + foo = "bar" + key = "value" + } } -`, testAccNetworkPreConditions(suffix), suffix, OS_AVAILABILITY_ZONE) +`, testAccNetworkPreConditions(suffix), suffix) } func testAccSFSTurbo_update(suffix string) string { return fmt.Sprintf(` %s +data "flexibleengine_availability_zones" "myaz" {} resource "flexibleengine_sfs_turbo" "sfs-turbo1" { - name = "sfs-turbo-acc-%s" - size = 600 - share_proto = "NFS" - vpc_id = flexibleengine_vpc_v1.test.id - subnet_id = flexibleengine_vpc_subnet_v1.test.id + name = "sfs-turbo-acc-%s" + size = 500 + share_proto = "NFS" + vpc_id = flexibleengine_vpc_v1.test.id + subnet_id = flexibleengine_vpc_subnet_v1.test.id security_group_id = flexibleengine_networking_secgroup_v2.secgroup.id - availability_zone = "%s" + availability_zone = data.flexibleengine_availability_zones.myaz.names[0] + + tags = { + foo = "bar_update" + key = "value_update" + } } -`, testAccNetworkPreConditions(suffix), suffix, OS_AVAILABILITY_ZONE) +`, testAccNetworkPreConditions(suffix), suffix) } func testAccSFSTurbo_crypt(suffix string) string { return fmt.Sprintf(` %s +data "flexibleengine_availability_zones" "myaz" {} + resource "flexibleengine_kms_key_v1" "key_1" { - key_alias = "kms-acc-%s" + key_alias = "kms-acc-%s" pending_days = "7" } resource "flexibleengine_sfs_turbo" "sfs-turbo1" { - name = "sfs-turbo-acc-%s" - size = 500 - share_proto = "NFS" - crypt_key_id = flexibleengine_kms_key_v1.key_1.id - vpc_id = flexibleengine_vpc_v1.test.id - subnet_id = flexibleengine_vpc_subnet_v1.test.id + name = "sfs-turbo-acc-%s" + size = 500 + share_proto = "NFS" + vpc_id = flexibleengine_vpc_v1.test.id + subnet_id = flexibleengine_vpc_subnet_v1.test.id security_group_id = flexibleengine_networking_secgroup_v2.secgroup.id - availability_zone = "%s" + availability_zone = data.flexibleengine_availability_zones.myaz.names[0] + crypt_key_id = flexibleengine_kms_key_v1.key_1.id } -`, testAccNetworkPreConditions(suffix), suffix, suffix, OS_AVAILABILITY_ZONE) +`, testAccNetworkPreConditions(suffix), suffix, suffix) } diff --git a/flexibleengine/provider.go b/flexibleengine/provider.go index 5f55422ee..9e8f12f5f 100644 --- a/flexibleengine/provider.go +++ b/flexibleengine/provider.go @@ -406,7 +406,6 @@ func Provider() *schema.Provider { "flexibleengine_vpc_peering_connection_accepter_v2": resourceVpcPeeringConnectionAccepterV2(), "flexibleengine_sfs_file_system_v2": resourceSFSFileSystemV2(), "flexibleengine_sfs_access_rule_v2": resourceSFSAccessRuleV2(), - "flexibleengine_sfs_turbo": resourceSFSTurbo(), "flexibleengine_rts_software_config_v1": resourceSoftwareConfigV1(), "flexibleengine_rts_stack_v1": resourceRTSStackV1(), "flexibleengine_compute_bms_server_v2": resourceComputeBMSInstanceV2(), @@ -550,6 +549,7 @@ func Provider() *schema.Provider { "flexibleengine_lb_member_v3": elb.ResourceMemberV3(), // v1.35.0 "flexibleengine_smn_topic_v2": smn.ResourceTopic(), // v1.39.0 "flexibleengine_smn_subscription_v2": smn.ResourceSubscription(), // v1.39.0 + "flexibleengine_sfs_turbo": huaweicloud.ResourceSFSTurbo(), // v1.41.0 // Deprecated resource "flexibleengine_as_group_v1": resourceASGroup(), diff --git a/flexibleengine/resource_flexibleengine_sfs_turbo.go b/flexibleengine/resource_flexibleengine_sfs_turbo.go deleted file mode 100644 index 3b655a62d..000000000 --- a/flexibleengine/resource_flexibleengine_sfs_turbo.go +++ /dev/null @@ -1,302 +0,0 @@ -package flexibleengine - -import ( - "fmt" - "log" - "strconv" - "time" - - "github.com/chnsz/golangsdk" - "github.com/chnsz/golangsdk/openstack/sfs_turbo/v1/shares" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -func resourceSFSTurbo() *schema.Resource { - return &schema.Resource{ - Create: resourceSFSTurboCreate, - Read: resourceSFSTurboRead, - Update: resourceSFSTurboUpdate, - Delete: resourceSFSTurboDelete, - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(10 * time.Minute), - Delete: schema.DefaultTimeout(10 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "region": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(4, 64), - }, - "size": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(500), - }, - "share_proto": { - Type: schema.TypeString, - Optional: true, - Default: "NFS", - ValidateFunc: validation.StringInSlice([]string{"NFS"}, false), - }, - "share_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: "STANDARD", - }, - "availability_zone": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "vpc_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "subnet_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "security_group_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "crypt_key_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "status": { - Type: schema.TypeString, - Computed: true, - }, - "version": { - Type: schema.TypeString, - Computed: true, - }, - "export_location": { - Type: schema.TypeString, - Computed: true, - }, - "available_capacity": { - Type: schema.TypeString, - Computed: true, - }, - }, - } -} - -func resourceSFSTurboCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*Config) - sfsClient, err := config.SfsV1Client(GetRegion(d, config)) - if err != nil { - return fmt.Errorf("Error creating FlexibleEngine SFS Turbo client: %s", err) - } - - share := shares.Share{ - Name: d.Get("name").(string), - Size: d.Get("size").(int), - ShareProto: d.Get("share_proto").(string), - ShareType: d.Get("share_type").(string), - VpcID: d.Get("vpc_id").(string), - SubnetID: d.Get("subnet_id").(string), - SecurityGroupID: d.Get("security_group_id").(string), - AvailabilityZone: d.Get("availability_zone").(string), - } - - metaOpts := shares.Metadata{} - if v, ok := d.GetOk("crypt_key_id"); ok { - metaOpts.CryptKeyID = v.(string) - } - share.Metadata = metaOpts - - createOpts := shares.CreateOpts{ - Share: share, - } - log.Printf("[DEBUG] create sfs turbo with option: %+v", createOpts) - create, err := shares.Create(sfsClient, createOpts).Extract() - if err != nil { - return fmt.Errorf("Error creating FlexibleEngine SFS Turbo: %s", err) - } - d.SetId(create.ID) - - stateConf := &resource.StateChangeConf{ - Pending: []string{"100"}, - Target: []string{"200"}, - Refresh: waitForSFSTurboStatus(sfsClient, create.ID), - Timeout: d.Timeout(schema.TimeoutCreate), - Delay: 20 * time.Second, - MinTimeout: 3 * time.Second, - } - _, StateErr := stateConf.WaitForState() - if StateErr != nil { - return fmt.Errorf("Error waiting for SFS Turbo (%s) to become ready: %s ", d.Id(), StateErr) - } - - return resourceSFSTurboRead(d, meta) -} - -func resourceSFSTurboRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*Config) - sfsClient, err := config.SfsV1Client(GetRegion(d, config)) - if err != nil { - return fmt.Errorf("Error creating FlexibleEngine SFS Turbo client: %s", err) - } - - n, err := shares.Get(sfsClient, d.Id()).Extract() - if err != nil { - return CheckDeleted(d, err, "Error retrieving SFS Turbo") - } - - d.Set("name", n.Name) - d.Set("share_proto", n.ShareProto) - d.Set("share_type", n.ShareType) - d.Set("vpc_id", n.VpcID) - d.Set("subnet_id", n.SubnetID) - d.Set("security_group_id", n.SecurityGroupID) - d.Set("version", n.Version) - d.Set("region", GetRegion(d, config)) - d.Set("availability_zone", n.AvailabilityZone) - d.Set("available_capacity", n.AvailCapacity) - d.Set("export_location", n.ExportLocation) - d.Set("crypt_key_id", n.CryptKeyID) - - // n.Size is a string of float64, should convert it to int - if fsize, err := strconv.ParseFloat(n.Size, 64); err == nil { - if err = d.Set("size", int(fsize)); err != nil { - return fmt.Errorf("Error reading size of SFS Turbo: %s", err) - } - } - - var status string - if n.SubStatus != "" { - status = n.SubStatus - } else { - status = n.Status - } - d.Set("status", status) - return nil -} - -func resourceSFSTurboUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*Config) - sfsClient, err := config.SfsV1Client(GetRegion(d, config)) - if err != nil { - return fmt.Errorf("Error updating FlexibleEngine SFS Turbo client: %s", err) - } - - if d.HasChange("size") { - old, newsize := d.GetChange("size") - if old.(int) > newsize.(int) { - return fmt.Errorf("Shrinking FlexibleEngine SFS Turbo size is not supported") - } - - expandOpts := shares.ExpandOpts{ - Extend: shares.ExtendOpts{NewSize: newsize.(int)}, - } - expand := shares.Expand(sfsClient, d.Id(), expandOpts) - if expand.Err != nil { - return fmt.Errorf("Error Expanding FlexibleEngine Share File size: %s", expand.Err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"121"}, - Target: []string{"221", "200"}, - Refresh: waitForSFSTurboSubStatus(sfsClient, d.Id()), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 10 * time.Second, - MinTimeout: 5 * time.Second, - } - - _, err = stateConf.WaitForState() - if err != nil { - return fmt.Errorf("Error deleting FlexibleEngine SFS Turbo: %s", err) - } - } - - return resourceSFSTurboRead(d, meta) -} - -func resourceSFSTurboDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*Config) - sfsClient, err := config.SfsV1Client(GetRegion(d, config)) - if err != nil { - return fmt.Errorf("Error creating FlexibleEngine SFS Turbo client: %s", err) - } - - err = shares.Delete(sfsClient, d.Id()).ExtractErr() - if err != nil { - return CheckDeleted(d, err, "Error deleting SFS Turbo") - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"100", "200"}, - Target: []string{"deleted"}, - Refresh: waitForSFSTurboStatus(sfsClient, d.Id()), - Timeout: d.Timeout(schema.TimeoutDelete), - Delay: 5 * time.Second, - MinTimeout: 3 * time.Second, - } - - _, err = stateConf.WaitForState() - if err != nil { - return fmt.Errorf("Error deleting FlexibleEngine SFS Turbo: %s", err) - } - - d.SetId("") - return nil -} - -func waitForSFSTurboStatus(sfsClient *golangsdk.ServiceClient, shareId string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - r, err := shares.Get(sfsClient, shareId).Extract() - if err != nil { - if _, ok := err.(golangsdk.ErrDefault404); ok { - log.Printf("[INFO] Successfully deleted FlexibleEngine shared File %s", shareId) - return r, "deleted", nil - } - return r, "error", err - } - - return r, r.Status, nil - } -} - -func waitForSFSTurboSubStatus(sfsClient *golangsdk.ServiceClient, shareId string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - r, err := shares.Get(sfsClient, shareId).Extract() - if err != nil { - if _, ok := err.(golangsdk.ErrDefault404); ok { - log.Printf("[INFO] Successfully deleted FlexibleEngine shared File %s", shareId) - return r, "deleted", nil - } - return r, "error", err - } - - var status string - if r.SubStatus != "" { - status = r.SubStatus - } else { - status = r.Status - } - return r, status, nil - } -} diff --git a/go.mod b/go.mod index d6dcd4319..5528f6d91 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.20 github.com/huaweicloud/terraform-provider-huaweicloud v1.50.0 github.com/jen20/awspolicyequivalence v1.1.0 + github.com/jmespath/go-jmespath v0.4.0 github.com/mitchellh/go-homedir v1.1.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -41,7 +42,6 @@ require ( github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4 // indirect github.com/mattn/go-colorable v0.1.12 // indirect