-
Notifications
You must be signed in to change notification settings - Fork 247
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
Modify alert_channel to use maps for headers, payload #81
Modify alert_channel to use maps for headers, payload #81
Conversation
A possible solution for newrelic#66 - this change: - un/marshalls headers and payload into separate maps - tests various configurations of these optional fields - documents these fields with examples
@paultyng when you have some time would you please review this PR? |
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.
Sorry for the delay on this, things are taking longer as we ship 0.12. I left a few comments regarding backwards compatibility. Maybe we should name these fields webhook_headers
and webhook_payload
just to be more explicit that they don't apply to the other types? Should we throw an error if they have data and its not a webhook
?
// extract headers from Configuration before we try and set it in the resource | ||
if headers, ok := channel.Configuration["headers"]; ok { | ||
d.Set("headers", headers) | ||
delete(channel.Configuration, "headers") |
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.
I'm a little hesitant to do this delete
as its a breaking change for anyone already using this behavior.
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.
I do not believe that the delete
could break anything because, as far as I can tell setting the headers or payload is broken currently
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.
I think nathanael-ness is right, I don't see how either headers
or payload
could be working currently with the type mismatch.
We're having to use a null-resource to deploy a webhook alert channel, can't use the resource as it is.
// extract payload from Configuration before we try and set it in the resource | ||
if payload, ok := channel.Configuration["payload"]; ok { | ||
d.Set("payload", payload) | ||
delete(channel.Configuration, "payload") |
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.
I'm a little hesitant to do this delete
as its a breaking change for anyone already using this behavior.
Also related: #45 |
And #18 |
Having reviewed the associated issues and thinking about how the code operates, I wanted to re-summarize the design. For most of it I'll talk about This PR adds the ability to specify the payload and headers as maps. This PR's proposed HCL example:
The comment raised by @paultyng seems like people may be doing this already to get through the API:
It's possible some users with simple headers are providing an explicit string in
We should catch the situation where the user mistakenly sets both fields, that may be in conflict, and issue a warning that helps clarify what they should do. Perhaps we change the field names to be more clear about this, such as So I think the proposal for updating this PR is:
Anything I've missed or that should also be considered? |
This issue has been open for a while now, does anyone have a work around? |
Related to paultyng/go-newrelic#52 |
The terraform docs here explain how to use the |
Closing this in favor of the implementation in #307. |
A possible solution for #66 - this change: