Skip to content
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

Merged
merged 3 commits into from
Oct 1, 2018

Conversation

nmuesch
Copy link
Contributor

@nmuesch nmuesch commented Oct 1, 2018

Stops using the GetOk method when updating the monitor struct for the new_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

@ghost ghost added the size/XS label Oct 1, 2018
@masci
Copy link
Contributor

masci commented Oct 1, 2018

Copy link
Contributor

@masci masci left a 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

if attr, ok := d.GetOk("new_host_delay"); ok {
o.SetNewHostDelay(attr.(int))
}
NewHostDelay := d.Get("new_host_delay")
Copy link
Contributor

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

@masci masci added this to the Next milestone Oct 1, 2018
o.SetNewHostDelay(attr.(int))
}
newHostDelay := d.Get("new_host_delay")
o.SetNewHostDelay(NewHostDelay.(int))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be newHostDelay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ Fixed

@masci masci merged commit 812eccf into DataDog:master Oct 1, 2018
nitrocode pushed a commit to nitrocode/terraform-provider-datadog that referenced this pull request Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants