Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nobl9-adam-szymanski committed Mar 6, 2024
1 parent ca92792 commit 2de5770
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nobl9/resource_alert_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func resourceAlertPolicy() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: "Indicates how long a given condition needs to be valid to mark the condition as true.",
DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool {
// To be backward compatible with lasts for with default=0m that was set before.
return oldValue == "0m" && newValue == ""
},
},
"alerting_window": {
Type: schema.TypeString,
Expand Down Expand Up @@ -193,8 +197,10 @@ func marshalAlertConditions(d *schema.ResourceData) []v1alphaAlertPolicy.AlertCo
lastsFor := condition["lasts_for"].(string)
alertingWindow := condition["alerting_window"].(string)

if lastsFor == "" && alertingWindow == "" {
lastsFor = "0m"
if lastsFor == "0m" && alertingWindow != "" {
// To be backward compatible with lasts for with default=0m that was set before, when user
// wants to switch to use alerting_window instead of lasts_for.
lastsFor = ""
}

resultConditions[i] = v1alphaAlertPolicy.AlertCondition{
Expand Down

0 comments on commit 2de5770

Please sign in to comment.