Skip to content

Commit

Permalink
Fix parsing on older versions of salt
Browse files Browse the repository at this point in the history
On older versions of salt, the message body is already a string which causes
the .([]byte) type assertion to fail. This catches that failure than then
tries an .(string) assertion to handle both cases.
  • Loading branch information
grimmy committed Aug 21, 2024
1 parent 3e614d1 commit 7dab529
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ func statemoduleResult(event event.SaltEvent) *bool {

// ParseEvent parses a salt event.
func (e Event) Parse(message map[string]interface{}) (event.SaltEvent, error) {
body := string(message["body"].([]byte))
var body string

if raw, ok := message["body"].([]byte); ok {
body = string(raw)
} else {
body = message["body"].(string)
}
lines := strings.SplitN(body, "\n\n", 2)

tag := lines[0]
Expand Down

0 comments on commit 7dab529

Please sign in to comment.