Skip to content

Commit d1f6b2d

Browse files
committed
refactor(monitor_alert_v2): remove deprecated trigger_after_minutes field
1 parent 389f186 commit d1f6b2d

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

sysdig/resource_sysdig_monitor_alert_v2_downtime.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,10 @@ func resourceSysdigMonitorAlertV2Downtime() *schema.Resource {
3232
},
3333

3434
Schema: createScopedSegmentedAlertV2Schema(createAlertV2Schema(map[string]*schema.Schema{
35-
"trigger_after_minutes": {
36-
Type: schema.TypeInt,
37-
Optional: true,
38-
Computed: true, // computed if range_seconds is defined
39-
Deprecated: "Use range_seconds instead",
40-
ValidateFunc: validation.IntAtLeast(1),
41-
},
4235
"range_seconds": {
4336
Type: schema.TypeInt,
4437
Optional: true,
4538
Computed: true, // computed if trigger_after_minutes is defined
46-
ExactlyOneOf: []string{"trigger_after_minutes"},
4739
ValidateFunc: validation.IntAtLeast(60),
4840
},
4941
"threshold": {
@@ -189,15 +181,6 @@ func buildAlertV2DowntimeStruct(d *schema.ResourceData) *v2.AlertV2Downtime {
189181
config.Range = d.Get("range_seconds").(int)
190182
}
191183

192-
if d.HasChange("trigger_after_minutes") {
193-
// GetOk returns true even if the value is stored only in the state and not in the user config:
194-
// to avoid applying a trigger_after_minutes old value from the state even if the user removed it from the config
195-
// we use HasChange that is true only if the user has changed (or created) it - and so it must be in the config
196-
if attr, ok := d.GetOk("trigger_after_minutes"); ok && attr != nil {
197-
config.Range = minutesToSeconds(d.Get("trigger_after_minutes").(int))
198-
}
199-
}
200-
201184
var unreportedAlertNotificationsRetentionSec *int
202185
if unreportedAlertNotificationsRetentionSecInterface, ok := d.GetOk("unreported_alert_notifications_retention_seconds"); ok {
203186
u := unreportedAlertNotificationsRetentionSecInterface.(int)
@@ -223,7 +206,6 @@ func updateAlertV2DowntimeState(d *schema.ResourceData, alert *v2.AlertV2Downtim
223206
return err
224207
}
225208

226-
_ = d.Set("trigger_after_minutes", secondsToMinutes(alert.Config.Range))
227209
_ = d.Set("range_seconds", alert.Config.Range)
228210

229211
_ = d.Set("threshold", (1-alert.Config.Threshold)*100)

website/docs/r/monitor_alert_v2_downtime.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ These arguments are common to all alerts in Sysdig Monitor.
4747

4848
* `name` - (Required) The name of the alert rule. It must be unique.
4949
* `description` - (Optional) The description of Monitor alert.
50-
* `range_seconds` - (Optional, required if `trigger_after_minutes` is not defined): The rolling time aggregation period in which the relevant metric data is evaluated.
51-
* `trigger_after_minutes` - (Optional, Deprecated) The rolling time aggregation period in which the relevant metric data is evaluated. Deprecated: use `range_seconds` instead.
50+
* `range_seconds` - (Optional): The rolling time aggregation period in which the relevant metric data is evaluated.
5251
* `group` - (Optional) Used to group alert rules in the UI. This value must be a lowercase string.
5352
* `severity` - (Optional) Severity of the Monitor alert. It must be `high`, `medium`, `low` or `info`. Default: `low`.
5453
* `enabled` - (Optional) Boolean that defines if the alert is enabled or not. Default: `true`.

0 commit comments

Comments
 (0)