Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/alicloud_resource_manager_shared_resource: Supported resource_type set to Snapshot #8021

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ func Provider() terraform.ResourceProvider {
"alicloud_privatelink_vpc_endpoint_zone": resourceAliCloudPrivateLinkVpcEndpointZone(),
"alicloud_ga_accelerator": resourceAliCloudGaAccelerator(),
"alicloud_eci_container_group": resourceAlicloudEciContainerGroup(),
"alicloud_resource_manager_shared_resource": resourceAlicloudResourceManagerSharedResource(),
"alicloud_resource_manager_shared_resource": resourceAliCloudResourceManagerSharedResource(),
"alicloud_resource_manager_shared_target": resourceAlicloudResourceManagerSharedTarget(),
"alicloud_ga_listener": resourceAliCloudGaListener(),
"alicloud_tsdb_instance": resourceAlicloudTsdbInstance(),
Expand Down
18 changes: 9 additions & 9 deletions alicloud/resource_alicloud_resource_manager_shared_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func resourceAlicloudResourceManagerSharedResource() *schema.Resource {
func resourceAliCloudResourceManagerSharedResource() *schema.Resource {
return &schema.Resource{
Create: resourceAlicloudResourceManagerSharedResourceCreate,
Read: resourceAlicloudResourceManagerSharedResourceRead,
Delete: resourceAlicloudResourceManagerSharedResourceDelete,
Create: resourceAliCloudResourceManagerSharedResourceCreate,
Read: resourceAliCloudResourceManagerSharedResourceRead,
Delete: resourceAliCloudResourceManagerSharedResourceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand All @@ -38,7 +38,7 @@ func resourceAlicloudResourceManagerSharedResource() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: StringInSlice([]string{"VSwitch", "ROSTemplate", "ServiceCatalogPortfolio", "PrefixList", "Image", "PublicIpAddressPool", "KMSInstance"}, false),
ValidateFunc: StringInSlice([]string{"VSwitch", "ROSTemplate", "ServiceCatalogPortfolio", "PrefixList", "Image", "PublicIpAddressPool", "KMSInstance", "Snapshot"}, false),
},
"status": {
Type: schema.TypeString,
Expand All @@ -48,7 +48,7 @@ func resourceAlicloudResourceManagerSharedResource() *schema.Resource {
}
}

func resourceAlicloudResourceManagerSharedResourceCreate(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudResourceManagerSharedResourceCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
resourcesharingService := ResourcesharingService{client}
var response map[string]interface{}
Expand Down Expand Up @@ -88,10 +88,10 @@ func resourceAlicloudResourceManagerSharedResourceCreate(d *schema.ResourceData,
return WrapErrorf(err, IdMsg, d.Id())
}

return resourceAlicloudResourceManagerSharedResourceRead(d, meta)
return resourceAliCloudResourceManagerSharedResourceRead(d, meta)
}

func resourceAlicloudResourceManagerSharedResourceRead(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudResourceManagerSharedResourceRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
resourcesharingService := ResourcesharingService{client}
object, err := resourcesharingService.DescribeResourceManagerSharedResource(d.Id())
Expand All @@ -117,7 +117,7 @@ func resourceAlicloudResourceManagerSharedResourceRead(d *schema.ResourceData, m
return nil
}

func resourceAlicloudResourceManagerSharedResourceDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudResourceManagerSharedResourceDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
parts, err := ParseResourceId(d.Id(), 3)
if err != nil {
Expand Down
38 changes: 19 additions & 19 deletions alicloud/resource_alicloud_resource_manager_shared_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccAlicloudResourceManagerSharedResource_basic(t *testing.T) {
func TestAccAliCloudResourceManagerSharedResource_basic(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_resource_manager_shared_resource.default"
ra := resourceAttrInit(resourceId, AlicloudResourceManagerSharedResourceMap)
ra := resourceAttrInit(resourceId, AliCloudResourceManagerSharedResourceMap)
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
return &ResourcesharingService{testAccProvider.Meta().(*connectivity.AliyunClient)}
}, "DescribeResourceManagerSharedResource")
rac := resourceAttrCheckInit(rc, ra)
testAccCheck := rac.resourceAttrMapUpdateSet()
rand := acctest.RandIntRange(10000, 99999)
name := fmt.Sprintf("tf-testAccResourceManagerSharedResource%d", rand)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudResourceManagerSharedResourceBasicDependence)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudResourceManagerSharedResourceBasicDependence)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
Expand Down Expand Up @@ -64,18 +64,18 @@ func TestAccAlicloudResourceManagerSharedResource_basic(t *testing.T) {
})
}

func TestAccAlicloudResourceManagerSharedResource_prefixList(t *testing.T) {
func TestAccAliCloudResourceManagerSharedResource_prefixList(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_resource_manager_shared_resource.default"
ra := resourceAttrInit(resourceId, AlicloudResourceManagerSharedResourceMap)
ra := resourceAttrInit(resourceId, AliCloudResourceManagerSharedResourceMap)
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
return &ResourcesharingService{testAccProvider.Meta().(*connectivity.AliyunClient)}
}, "DescribeResourceManagerSharedResource")
rac := resourceAttrCheckInit(rc, ra)
testAccCheck := rac.resourceAttrMapUpdateSet()
rand := acctest.RandIntRange(10000, 99999)
name := fmt.Sprintf("tf-testAccResourceManagerSharedResource%d", rand)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudResourceManagerSharedResourcePrefixListDependence)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudResourceManagerSharedResourcePrefixListDependence)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
Expand Down Expand Up @@ -108,18 +108,18 @@ func TestAccAlicloudResourceManagerSharedResource_prefixList(t *testing.T) {
})
}

func TestAccAlicloudResourceManagerSharedResource_image(t *testing.T) {
func TestAccAliCloudResourceManagerSharedResource_image(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_resource_manager_shared_resource.default"
ra := resourceAttrInit(resourceId, AlicloudResourceManagerSharedResourceMap)
ra := resourceAttrInit(resourceId, AliCloudResourceManagerSharedResourceMap)
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
return &ResourcesharingService{testAccProvider.Meta().(*connectivity.AliyunClient)}
}, "DescribeResourceManagerSharedResource")
rac := resourceAttrCheckInit(rc, ra)
testAccCheck := rac.resourceAttrMapUpdateSet()
rand := acctest.RandIntRange(10000, 99999)
name := fmt.Sprintf("tf-testAccResourceManagerSharedResource%d", rand)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudResourceManagerSharedResourceImageDependence)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudResourceManagerSharedResourceImageDependence)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
Expand Down Expand Up @@ -152,11 +152,11 @@ func TestAccAlicloudResourceManagerSharedResource_image(t *testing.T) {
})
}

var AlicloudResourceManagerSharedResourceMap = map[string]string{
var AliCloudResourceManagerSharedResourceMap = map[string]string{
"status": "Associated",
}

func AlicloudResourceManagerSharedResourceBasicDependence(name string) string {
func AliCloudResourceManagerSharedResourceBasicDependence(name string) string {
return fmt.Sprintf(`
variable "name" {
default = "%s"
Expand All @@ -181,7 +181,7 @@ func AlicloudResourceManagerSharedResourceBasicDependence(name string) string {
`, name)
}

func AlicloudResourceManagerSharedResourcePrefixListDependence(name string) string {
func AliCloudResourceManagerSharedResourcePrefixListDependence(name string) string {
return fmt.Sprintf(`
variable "name" {
default = "%s"
Expand All @@ -204,7 +204,7 @@ func AlicloudResourceManagerSharedResourcePrefixListDependence(name string) stri
`, name)
}

func AlicloudResourceManagerSharedResourceImageDependence(name string) string {
func AliCloudResourceManagerSharedResourceImageDependence(name string) string {
return fmt.Sprintf(`
variable "name" {
default = "%s"
Expand Down Expand Up @@ -267,7 +267,7 @@ func AlicloudResourceManagerSharedResourceImageDependence(name string) string {
`, name)
}

func TestUnitAlicloudResourceManagerSharedResource(t *testing.T) {
func TestUnitAliCloudResourceManagerSharedResource(t *testing.T) {
p := Provider().(*schema.Provider).ResourcesMap
dInit, _ := schema.InternalMap(p["alicloud_resource_manager_shared_resource"].Schema).Data(nil, nil)
dExisted, _ := schema.InternalMap(p["alicloud_resource_manager_shared_resource"].Schema).Data(nil, nil)
Expand Down Expand Up @@ -341,7 +341,7 @@ func TestUnitAlicloudResourceManagerSharedResource(t *testing.T) {
StatusCode: tea.Int(400),
}
})
err = resourceAlicloudResourceManagerSharedResourceCreate(dInit, rawClient)
err = resourceAliCloudResourceManagerSharedResourceCreate(dInit, rawClient)
patches.Reset()
assert.NotNil(t, err)
ReadMockResponseDiff := map[string]interface{}{
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestUnitAlicloudResourceManagerSharedResource(t *testing.T) {
}
return ReadMockResponse, nil
})
err := resourceAlicloudResourceManagerSharedResourceCreate(dInit, rawClient)
err := resourceAliCloudResourceManagerSharedResourceCreate(dInit, rawClient)
patches.Reset()
switch errorCode {
case "NonRetryableError":
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestUnitAlicloudResourceManagerSharedResource(t *testing.T) {
}
return ReadMockResponse, nil
})
err := resourceAlicloudResourceManagerSharedResourceRead(dExisted, rawClient)
err := resourceAliCloudResourceManagerSharedResourceRead(dExisted, rawClient)
patches.Reset()
switch errorCode {
case "NonRetryableError":
Expand All @@ -437,7 +437,7 @@ func TestUnitAlicloudResourceManagerSharedResource(t *testing.T) {
StatusCode: tea.Int(400),
}
})
err = resourceAlicloudResourceManagerSharedResourceDelete(dExisted, rawClient)
err = resourceAliCloudResourceManagerSharedResourceDelete(dExisted, rawClient)
patches.Reset()
assert.NotNil(t, err)
attributesDiff = map[string]interface{}{}
Expand Down Expand Up @@ -472,7 +472,7 @@ func TestUnitAlicloudResourceManagerSharedResource(t *testing.T) {
}
return ReadMockResponse, nil
})
err := resourceAlicloudResourceManagerSharedResourceDelete(dExisted, rawClient)
err := resourceAliCloudResourceManagerSharedResourceDelete(dExisted, rawClient)
patches.Reset()
switch errorCode {
case "NonRetryableError":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The following arguments are supported:
- The following types are added after v1.192.0: `PrefixList` and `Image`.
- The following types are added after v1.194.1: `PublicIpAddressPool`.
- The following types are added after v1.208.0: `KMSInstance`.
- The following types are added after v1.240.0: `Snapshot`.

## Attributes Reference

Expand Down
Loading