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

Delete Over Count Bug Fix #3946

Merged
merged 1 commit into from
Aug 17, 2022
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 examples/ibm-is-ng/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ resource "ibm_is_backup_policy_plan" "is_backup_policy_plan" {
copy_user_tags = true
deletion_trigger {
delete_after = 20
delete_over_count = 20
delete_over_count = "20"
}
name = "my-backup-policy-plan-1"
}
Expand Down
10 changes: 6 additions & 4 deletions ibm/service/vpc/resource_ibm_is_backup_policy_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,18 @@ func resourceIBMIsBackupPolicyPlanCreate(context context.Context, d *schema.Reso
if backupPolicyPlanDeletionTriggerPrototypeMap["delete_after"] != nil {
backupPolicyPlanDeletionTriggerPrototype.DeleteAfter = core.Int64Ptr(int64(backupPolicyPlanDeletionTriggerPrototypeMap["delete_after"].(int)))
}
log.Println("backupPolicyPlanDeletionTriggerPrototypeMap[delete_over_count] Inside")
log.Println(backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"])
if backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"] != nil {
deleteOverCountString := backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"].(string)
if deleteOverCountString != "" {
if deleteOverCountString != "" && deleteOverCountString != "null" {
deleteOverCount, err := strconv.ParseInt(backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"].(string), 10, 64)
if err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting delete_over_count: %s", err))
}
deleteOverCountint := int64(deleteOverCount)
if deleteOverCountint >= int64(0) {
backupPolicyPlanDeletionTriggerPrototype.DeleteOverCount = core.Int64Ptr(deleteOverCountint)
} else {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting delete_over_count: Retention count and days cannot be both zero"))
}
}
}
Expand Down Expand Up @@ -310,6 +310,8 @@ func resourceIBMIsBackupPolicyPlanBackupPolicyPlanDeletionTriggerPrototypeToMap(
}
if backupPolicyPlanDeletionTriggerPrototype.DeleteOverCount != nil {
backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"] = strconv.FormatInt(*backupPolicyPlanDeletionTriggerPrototype.DeleteOverCount, 10)
} else {
backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"] = "null"
}

return backupPolicyPlanDeletionTriggerPrototypeMap
Expand Down Expand Up @@ -360,7 +362,7 @@ func resourceIBMIsBackupPolicyPlanUpdate(context context.Context, d *schema.Reso
}
if backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"] != nil {
deleteOverCountString := backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"].(string)
if deleteOverCountString != "" {
if deleteOverCountString != "" && deleteOverCountString != "null" {
deleteOverCount, err := strconv.ParseInt(backupPolicyPlanDeletionTriggerPrototypeMap["delete_over_count"].(string), 10, 64)
if err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting delete_over_count: %s", err))
Expand Down
5 changes: 4 additions & 1 deletion website/docs/r/is_backup_policy_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ backup_policy_plan_id

Nested scheme for `deletion_trigger`:
- `delete_after` - (Optional, Integer) The maximum number of days to keep each backup after creation. Default value is 30.
- `delete_over_count` - (Optional, Integer) The maximum number of recent backups to keep. If unspecified, there will be no maximum.
- `delete_over_count` - (Optional, String) The maximum number of recent backups to keep. If unspecified, there will be no maximum.

->**Note** Assign back to "null" to reset to no maximum.

- `name` - (Optional, String) The user-defined name for this backup policy plan. Names must be unique within the backup policy this plan resides in. If unspecified, the name will be a hyphenated list of randomly-selected words.

## Attribute Reference
Expand Down