Skip to content

Commit 65d0ef9

Browse files
committed
refactor(monitor_alert_v2): remove deprecated trigger_after_minutes field
1 parent 60c28bc commit 65d0ef9

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

sysdig/resource_sysdig_monitor_alert_v2_prometheus.go

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

3434
Schema: createAlertV2Schema(map[string]*schema.Schema{
35-
"trigger_after_minutes": {
36-
Type: schema.TypeInt,
37-
Optional: true,
38-
Computed: true, // computed if duration_seconds is defined
39-
Deprecated: "Use duration_seconds instead",
40-
ValidateFunc: validation.IntAtLeast(0),
41-
},
4235
"duration_seconds": {
4336
Type: schema.TypeInt,
4437
Optional: true,
4538
Computed: true, // computed if trigger_after_minutes is defined
46-
ConflictsWith: []string{"trigger_after_minutes"},
4739
ValidateFunc: validation.IntAtLeast(0),
4840
},
4941
"query": {
@@ -171,15 +163,6 @@ func buildAlertV2PrometheusStruct(d *schema.ResourceData) *v2.AlertV2Prometheus
171163
config.Duration = d.Get("duration_seconds").(int)
172164
}
173165

174-
if d.HasChange("trigger_after_minutes") {
175-
// GetOk returns true even if the value is stored only in the state and not in the user config:
176-
// to avoid applying a trigger_after_minutes old value from the state even if the user removed it from the config
177-
// we use HasChange that is true only if the user has changed (or created) it - and so it must be in the config
178-
if attr, ok := d.GetOk("trigger_after_minutes"); ok && attr != nil {
179-
config.Duration = minutesToSeconds(d.Get("trigger_after_minutes").(int))
180-
}
181-
}
182-
183166
alert := &v2.AlertV2Prometheus{
184167
AlertV2Common: *alertV2Common,
185168
Config: config,
@@ -193,7 +176,6 @@ func updateAlertV2PrometheusState(d *schema.ResourceData, alert *v2.AlertV2Prome
193176
return
194177
}
195178

196-
_ = d.Set("trigger_after_minutes", secondsToMinutes(alert.Config.Duration))
197179
_ = d.Set("duration_seconds", alert.Config.Duration)
198180

199181
_ = d.Set("query", alert.Config.Query)

website/docs/r/monitor_alert_v2_prometheus.md

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

4141
* `name` - (Required) The name of the alert rule. It must be unique.
4242
* `description` - (Optional) The description of Monitor alert.
43-
* `duration_seconds` - (Optional, cannot be used with `trigger_after_minutes`) Specifies the amount of time, in seconds, that an alert condition must remain continuously true before the alert rule is triggered.
44-
* `trigger_after_minutes` - (Optional, Deprecated, cannot be used with `duration_seconds`) Specifies the amount of time, in minutes, that an alert condition must remain continuously true before the alert rule is triggered. Deprecated: use `duration_seconds` instead.
43+
* `duration_seconds` - (Optional) Specifies the amount of time, in seconds, that an alert condition must remain continuously true before the alert rule is triggered.
4544
* `group` - (Optional) Used to group alert rules in the UI. This value must be a lowercase string.
4645
* `severity` - (Optional) Severity of the Monitor alert. It must be `high`, `medium`, `low` or `info`. Default: `low`.
4746
* `enabled` - (Optional) Boolean that defines if the alert is enabled or not. Default: `true`.

0 commit comments

Comments
 (0)