From bef1b58fda6d06c19bc9a47feb65c53b12670802 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Thu, 5 May 2016 16:49:35 -0700 Subject: [PATCH] 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. --- builtin/providers/datadog/resource_datadog_monitor.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/builtin/providers/datadog/resource_datadog_monitor.go b/builtin/providers/datadog/resource_datadog_monitor.go index 266c7bf28f..92534edf04 100644 --- a/builtin/providers/datadog/resource_datadog_monitor.go +++ b/builtin/providers/datadog/resource_datadog_monitor.go @@ -135,7 +135,7 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor { } o.Silenced = s } - if attr, ok := d.GetOk("notify_data"); ok { + if attr, ok := d.GetOk("notify_no_data"); ok { o.NotifyNoData = attr.(bool) } if attr, ok := d.GetOk("no_data_timeframe"); ok { @@ -153,9 +153,6 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor { if attr, ok := d.GetOk("escalation_message"); ok { o.EscalationMessage = attr.(string) } - if attr, ok := d.GetOk("escalation_message"); ok { - o.EscalationMessage = attr.(string) - } if attr, ok := d.GetOk("include_tags"); ok { o.IncludeTags = attr.(bool) } @@ -226,7 +223,7 @@ func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error d.Set("type", m.Type) d.Set("thresholds", m.Options.Thresholds) d.Set("notify_no_data", m.Options.NotifyNoData) - d.Set("notify_no_data_timeframe", m.Options.NoDataTimeframe) + d.Set("no_data_timeframe", m.Options.NoDataTimeframe) d.Set("renotify_interval", m.Options.RenotifyInterval) d.Set("notify_audit", m.Options.NotifyAudit) d.Set("timeout_h", m.Options.TimeoutH) @@ -275,7 +272,7 @@ func resourceDatadogMonitorUpdate(d *schema.ResourceData, meta interface{}) erro if attr, ok := d.GetOk("notify_no_data"); ok { o.NotifyNoData = attr.(bool) } - if attr, ok := d.GetOk("notify_no_data_timeframe"); ok { + if attr, ok := d.GetOk("no_data_timeframe"); ok { o.NoDataTimeframe = attr.(int) } if attr, ok := d.GetOk("renotify_interval"); ok {