Copilot commented on code in PR #268:
URL:
https://github.com/apache/cloudstack-terraform-provider/pull/268#discussion_r2598556902
##########
cloudstack/resource_cloudstack_disk.go:
##########
@@ -92,13 +92,18 @@ func resourceCloudStackDisk() *schema.Resource {
ForceNew: true,
},
- "tags": tagsSchema(),
-
"reattach_on_change": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
+
+ "deleteprotection": {
+ Type: schema.TypeBool,
+ Optional: true,
Review Comment:
The `deleteprotection` field should be marked as `Computed: true` in
addition to `Optional: true`. This allows Terraform to properly track the value
when it's read back from the API, ensuring state synchronization and preventing
unnecessary diffs.
Similar to the `attach` field (lines 47-51), update the schema to:
```go
"deleteprotection": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
```
```suggestion
Optional: true,
Computed: true,
```
##########
cloudstack/resource_cloudstack_disk.go:
##########
@@ -147,6 +152,21 @@ func resourceCloudStackDiskCreate(d *schema.ResourceData,
meta interface{}) erro
// Set the volume ID and partials
d.SetId(r.Id)
+ // Set deleteprotection using UpdateVolume
+ if v, ok := d.GetOk("deleteprotection"); ok {
+ // p_update := cs.Volume.NewUpdateVolumeParams()
+ // p_update.SetDeleteprotection(v.(bool))
Review Comment:
Commented-out code should be removed. If this code is not needed, it should
be deleted rather than left as a comment.
```suggestion
```
##########
cloudstack/resource_cloudstack_instance.go:
##########
@@ -479,6 +484,20 @@ func resourceCloudStackInstanceCreate(d
*schema.ResourceData, meta interface{})
d.SetId(r.Id)
+ // Set deleteprotection using UpdateVirtualMachine
+ if v, ok := d.GetOk("deleteprotection"); ok {
+ // p_update :=
cs.VirtualMachine.NewUpdateVirtualMachineParams(r.Id)
+ // p_update.SetDeleteprotection(v.(bool))
Review Comment:
Commented-out code should be removed. If this code is not needed, it should
be deleted rather than left as a comment.
```suggestion
```
##########
cloudstack/resource_cloudstack_instance.go:
##########
@@ -249,6 +249,11 @@ func resourceCloudStackInstance() *schema.Resource {
Optional: true,
},
+ "deleteprotection": {
+ Type: schema.TypeBool,
+ Optional: true,
Review Comment:
The `deleteprotection` field should be marked as `Computed: true` in
addition to `Optional: true`. This allows Terraform to properly track the value
when it's read back from the API, ensuring state synchronization and preventing
unnecessary diffs.
Update the schema to:
```go
"deleteprotection": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
```
```suggestion
Optional: true,
Computed: true,
```
##########
website/docs/r/disk.html.markdown:
##########
@@ -56,6 +56,9 @@ The following arguments are supported:
* `reattach_on_change` - (Optional) Determines whether or not to detach the
disk volume
from the virtual machine on disk offering or size change.
+* `deleteprotection` - (Optional) Set delete protection for the volume. If
true, The volume will be protected from deletion.
Review Comment:
Capitalization inconsistency: "The" should be lowercase as it continues from
"If true,".
```suggestion
* `deleteprotection` - (Optional) Set delete protection for the volume. If
true, the volume will be protected from deletion.
```
--
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]