Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Convert AlertInfraCondition thresholds to pointers #16

Merged
merged 1 commit into from
Jun 1, 2018

Conversation

paul91
Copy link
Contributor

@paul91 paul91 commented May 31, 2018

Let me know if there is a better way to do this. The idea is that this makes it much easier to determine if these things aren't set in terraform-provider-newrelic as an optional parameter so it can be properly omitted, ie:

if attr, ok := d.GetOk("warning"); ok {
	// blahblahblah
}

If an empty warning threshold gets sent to the API it creates an invalid Alert Condition that can no longer be described without a GET resulting in a 500.

@paultyng
Copy link
Owner

paultyng commented Jun 1, 2018

I don't know if it works for the cases you are looking at, but since structs are comparable in Go:

Struct values are comparable if all their fields are comparable. Two struct values are equal if their corresponding non-blank fields are equal.

So you could just check for equality to a zero value struct. But nil is probably better, just unfortunate that its a breaking change, I'll merge and do a major version bump.

@paultyng paultyng merged commit f5cd966 into paultyng:master Jun 1, 2018
@paultyng
Copy link
Owner

paultyng commented Jun 1, 2018

Released as v2.0.0

ianrayns pushed a commit to ianrayns/go-newrelic that referenced this pull request May 7, 2019
vendor: github.com/hashicorp/terraform/...@v0.10.0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants