-
Notifications
You must be signed in to change notification settings - Fork 55
add support for enabling delete protection #268
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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, | ||||
| }, | ||||
|
|
||||
| "tags": tagsSchema(), | ||||
| }, | ||||
| } | ||||
| } | ||||
|
|
@@ -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)) | ||||
|
||||
| // p_update.SetDeleteprotection(v.(bool)) |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -249,6 +249,11 @@ func resourceCloudStackInstance() *schema.Resource { | |||||||
| Optional: true, | ||||||||
| }, | ||||||||
|
|
||||||||
| "deleteprotection": { | ||||||||
| Type: schema.TypeBool, | ||||||||
| Optional: true, | ||||||||
|
||||||||
| Optional: true, | |
| Optional: true, | |
| Computed: true, |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented-out code should be removed. If this code is not needed, it should be deleted rather than left as a comment.
| // p_update.SetDeleteprotection(v.(bool)) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
||||||
| * `deleteprotection` - (Optional) Set delete protection for the volume. If true, The volume will be protected from deletion. | |
| * `deleteprotection` - (Optional) Set delete protection for the volume. If true, the volume will be protected from deletion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
deleteprotectionfield should be marked asComputed: truein addition toOptional: 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
attachfield (lines 47-51), update the schema to: