Conversation
| if pagerDutyEventAction, isActionPresent := sensuToPagerDutyEventType[action]; isActionPresent { | ||
| return pagerDutyEventAction, nil | ||
| } | ||
| return sensuToPagerDutyEventType["create"], nil |
There was a problem hiding this comment.
Just for my own understanding: Is this the expected behavior that Sensu "action" values other than create and resolve will also become PagerDuty trigger?
If so that may warrant a comment?
There was a problem hiding this comment.
Yeah from the current pdagent code that seems like that's what we're doing: https://github.com/PagerDuty/pdagent-integrations/blob/master/bin/pd-sensu#L79-L83, I'll add a comment for sure. Added here: dc34a73
| @@ -0,0 +1,31 @@ | |||
| package cmdutil | |||
There was a problem hiding this comment.
Maybe a more descriptive name for this file would be json something like that?
There was a problem hiding this comment.
Renamed this file to mapConversion.go for clarity, and since the only thing this file contains now is the StringMapToInterfaceMap function. 2ca6bd8
|
|
||
| import "strings" | ||
|
|
||
| func GetNestedStringField(inputMap map[string]interface{}, selector string) (string, bool) { |
There was a problem hiding this comment.
This might be ever-so-slightly cleaner if we accepted keys ...string instead of having to parse a selector format.
There was a problem hiding this comment.
I'll resolve the other comments on this function since I kind of changed how this is done. I think you're right that getting nested field function was doing a little too much when all we really need it to get something nested one layer deep. Took a different approach here: f9d92db. I decided not to use gjson because this method is used in the zabbix integration which does not use json data. The data should stay in map[string]interface{} format in sensu and zabbix to be able to chare map accessor and validation code
9abc27e to
9b90c3d
Compare
| @@ -1,5 +1,21 @@ | |||
| package cmdutil | |||
|
|
|||
| func ValidateMapFieldIsString(inputMap map[string]interface{}, selector string) (string, bool) { | |||
There was a problem hiding this comment.
I'm going to delete these since they do not seem to be used.
1f8ccb9 to
391da5e
Compare
ChezCrawford
left a comment
There was a problem hiding this comment.
This looks great Lewis. Thanks for sticking with it.
Adds Sensu integration support.