-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow new_host_delay to be unset #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small style nit but LGTM
datadog/resource_datadog_monitor.go
Outdated
if attr, ok := d.GetOk("new_host_delay"); ok { | ||
o.SetNewHostDelay(attr.(int)) | ||
} | ||
NewHostDelay := d.Get("new_host_delay") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: s/NewHostDelay
/newHostDelay
datadog/resource_datadog_monitor.go
Outdated
o.SetNewHostDelay(attr.(int)) | ||
} | ||
newHostDelay := d.Get("new_host_delay") | ||
o.SetNewHostDelay(NewHostDelay.(int)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be newHostDelay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ Fixed
Allow new_host_delay to be unset
Stops using the
GetOk
method when updating the monitor struct for thenew_host_delay
parameter.The GetOk method does a check both to see if the key is specified in the schema configuration AND is not the golang zero value for that type. So Using the GetOk function, specifying a
new_host_delay: 0
would actually cause the default to be used.It seems like GetOk shouldn't be used for an int type that has a default value if
0
is an allowed value for that key.Get-ing the key (the change introduced in this PR), you can specify a 0 value to mean
0
or specify no value to fallback to the default.Alternatively, we could use the
GetOkExists
function, but that is only available starting with Terraform 0.10.1 and this provider currently pins the helpers library at 0.10.0