Skip to content

Commit bef1b58

Browse files
committed
provider/datadog: fix code to match schema
On Create, notify_no_data was being ignored. On Read and Update, no_data_timeframe was being misused. There was also a redundant read of escalation_message on Create.
1 parent df4ccdf commit bef1b58

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

builtin/providers/datadog/resource_datadog_monitor.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor {
135135
}
136136
o.Silenced = s
137137
}
138-
if attr, ok := d.GetOk("notify_data"); ok {
138+
if attr, ok := d.GetOk("notify_no_data"); ok {
139139
o.NotifyNoData = attr.(bool)
140140
}
141141
if attr, ok := d.GetOk("no_data_timeframe"); ok {
@@ -153,9 +153,6 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor {
153153
if attr, ok := d.GetOk("escalation_message"); ok {
154154
o.EscalationMessage = attr.(string)
155155
}
156-
if attr, ok := d.GetOk("escalation_message"); ok {
157-
o.EscalationMessage = attr.(string)
158-
}
159156
if attr, ok := d.GetOk("include_tags"); ok {
160157
o.IncludeTags = attr.(bool)
161158
}
@@ -226,7 +223,7 @@ func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error
226223
d.Set("type", m.Type)
227224
d.Set("thresholds", m.Options.Thresholds)
228225
d.Set("notify_no_data", m.Options.NotifyNoData)
229-
d.Set("notify_no_data_timeframe", m.Options.NoDataTimeframe)
226+
d.Set("no_data_timeframe", m.Options.NoDataTimeframe)
230227
d.Set("renotify_interval", m.Options.RenotifyInterval)
231228
d.Set("notify_audit", m.Options.NotifyAudit)
232229
d.Set("timeout_h", m.Options.TimeoutH)
@@ -275,7 +272,7 @@ func resourceDatadogMonitorUpdate(d *schema.ResourceData, meta interface{}) erro
275272
if attr, ok := d.GetOk("notify_no_data"); ok {
276273
o.NotifyNoData = attr.(bool)
277274
}
278-
if attr, ok := d.GetOk("notify_no_data_timeframe"); ok {
275+
if attr, ok := d.GetOk("no_data_timeframe"); ok {
279276
o.NoDataTimeframe = attr.(int)
280277
}
281278
if attr, ok := d.GetOk("renotify_interval"); ok {

0 commit comments

Comments
 (0)