Skip to content

Commit

Permalink
Delete Over Count Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SunithaGudisagarIBM1 committed Aug 12, 2022
1 parent dcdcef7 commit f5759a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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

0 comments on commit f5759a9

Please sign in to comment.