sudo87 commented on code in PR #268:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/268#discussion_r3794396296


##########
cloudstack/resource_cloudstack_instance_test.go:
##########
@@ -295,6 +295,45 @@ func TestAccCloudStackInstance_userData(t *testing.T) {
        })
 }
 
+func TestAccCloudStackInstance_deleteProtection(t *testing.T) {
+       var instance cloudstack.VirtualMachine
+
+       resource.Test(t, resource.TestCase{
+               PreCheck:     func() { testAccPreCheck(t) },
+               Providers:    testAccProviders,
+               CheckDestroy: testAccCheckCloudStackDiskDestroy,

Review Comment:
   Good catch, this was checking the wrong resource type. Fixed in 1d23c72 — 
now uses `testAccCheckCloudStackInstanceDestroy`.



##########
cloudstack/resource_cloudstack_instance.go:
##########
@@ -249,6 +249,12 @@ func resourceCloudStackInstance() *schema.Resource {
                                Optional: true,
                        },
 
+                       "delete_protection": {
+                               Type:     schema.TypeBool,
+                               Optional: true,
+                               Computed: true,

Review Comment:
   You're right, Read wasn't populating this at all. Added 
`d.Set("delete_protection", vm.Deleteprotection)` in 1d23c72 so import and 
out-of-band changes get picked up.



##########
cloudstack/resource_cloudstack_disk.go:
##########
@@ -92,13 +92,19 @@ func resourceCloudStackDisk() *schema.Resource {
                                ForceNew: true,
                        },
 
-                       "tags": tagsSchema(),
-
                        "reattach_on_change": {
                                Type:     schema.TypeBool,
                                Optional: true,
                                Default:  false,
                        },
+
+                       "delete_protection": {
+                               Type:     schema.TypeBool,
+                               Optional: true,
+                               Computed: true,

Review Comment:
   Same gap on the disk side. Added `d.Set("delete_protection", 
v.Deleteprotection)` in `resourceCloudStackDiskRead` in 1d23c72.



##########
cloudstack/resource_cloudstack_disk.go:
##########
@@ -92,13 +92,19 @@ func resourceCloudStackDisk() *schema.Resource {
                                ForceNew: true,
                        },
 
-                       "tags": tagsSchema(),
-
                        "reattach_on_change": {
                                Type:     schema.TypeBool,
                                Optional: true,
                                Default:  false,
                        },
+
+                       "delete_protection": {

Review Comment:
   No — a `Default` isn't valid alongside `Computed: true` 
(terraform-plugin-sdk rejects that combo at provider init with "Default must be 
nil if computed"). Leaving it unset is intentional: Terraform just picks up 
whatever CloudStack reports on read/import, which is false unless explicitly 
enabled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to