Skip to content

Commit a00a902

Browse files
committed
provider/datadog: Adding default values to datadog_monitor (hashicorp#12168)
Fixes: hashicorp#8055 Fixes: hashicorp#10264 Fixes: hashicorp#10881 We have swapped from using d.GetOk (as that func returns nil when a default value is used) and moved to using default values that we can pass directly to the Struct. The fact we have default values, means that we can use d.Get which will work here ``` % make testacc TEST=./builtin/providers/datadog ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/22 18:56:03 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/datadog -v -timeout 120m === RUN TestDatadogMonitor_import --- PASS: TestDatadogMonitor_import (8.66s) === RUN TestProvider --- PASS: TestProvider (0.00s) === RUN TestProvider_impl --- PASS: TestProvider_impl (0.00s) === RUN TestAccDatadogMonitor_Basic --- PASS: TestAccDatadogMonitor_Basic (5.68s) === RUN TestAccDatadogMonitor_BasicNoTreshold --- PASS: TestAccDatadogMonitor_BasicNoTreshold (3.13s) === RUN TestAccDatadogMonitor_Updated --- PASS: TestAccDatadogMonitor_Updated (6.41s) === RUN TestAccDatadogMonitor_TrimWhitespace --- PASS: TestAccDatadogMonitor_TrimWhitespace (3.22s) === RUN TestAccDatadogMonitor_Basic_float_int --- PASS: TestAccDatadogMonitor_Basic_float_int (5.50s) === RUN TestAccDatadogTimeboard_update --- PASS: TestAccDatadogTimeboard_update (8.35s) === RUN TestValidateAggregatorMethod --- PASS: TestValidateAggregatorMethod (0.00s) PASS ok github.com/hashicorp/terraform/builtin/providers/datadog 40.954s ```
1 parent 6d2659c commit a00a902

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎builtin/providers/datadog/resource_datadog_monitor.go‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func resourceDatadogMonitor() *schema.Resource {
104104
"require_full_window": &schema.Schema{
105105
Type: schema.TypeBool,
106106
Optional: true,
107+
Default: true,
107108
},
108109
"locked": &schema.Schema{
109110
Type: schema.TypeBool,
@@ -122,6 +123,7 @@ func resourceDatadogMonitor() *schema.Resource {
122123
"include_tags": &schema.Schema{
123124
Type: schema.TypeBool,
124125
Optional: true,
126+
Default: true,
125127
},
126128
"tags": &schema.Schema{
127129
Type: schema.TypeList,
@@ -147,8 +149,10 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor {
147149
}
148150

149151
o := datadog.Options{
150-
Thresholds: &thresholds,
151-
NotifyNoData: datadog.Bool(d.Get("notify_no_data").(bool)),
152+
Thresholds: &thresholds,
153+
NotifyNoData: datadog.Bool(d.Get("notify_no_data").(bool)),
154+
RequireFullWindow: datadog.Bool(d.Get("require_full_window").(bool)),
155+
IncludeTags: datadog.Bool(d.Get("include_tags").(bool)),
152156
}
153157
if attr, ok := d.GetOk("silenced"); ok {
154158
s := make(map[string]int)
@@ -179,12 +183,6 @@ func buildMonitorStruct(d *schema.ResourceData) *datadog.Monitor {
179183
if attr, ok := d.GetOk("escalation_message"); ok {
180184
o.SetEscalationMessage(attr.(string))
181185
}
182-
if attr, ok := d.GetOk("include_tags"); ok {
183-
o.SetIncludeTags(attr.(bool))
184-
}
185-
if attr, ok := d.GetOk("require_full_window"); ok {
186-
o.SetRequireFullWindow(attr.(bool))
187-
}
188186
if attr, ok := d.GetOk("locked"); ok {
189187
o.SetLocked(attr.(bool))
190188
}

0 commit comments

Comments
 (0)