Skip to content

Commit

Permalink
Fix OpsGenie Teams field (#1101)
Browse files Browse the repository at this point in the history
* Fix OpsGenie Teams field

* Remove use of opsGenieTeam struct
  • Loading branch information
Tom-Fawcett authored and stuartnelson3 committed Nov 15, 2017
1 parent 10ed603 commit 291fc57
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions notify/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,15 +784,15 @@ func NewOpsGenie(c *config.OpsGenieConfig, t *template.Template, l log.Logger) *
}

type opsGenieCreateMessage struct {
Alias string `json:"alias"`
Message string `json:"message"`
Description string `json:"description,omitempty"`
Details map[string]string `json:"details"`
Source string `json:"source"`
Teams string `json:"teams,omitempty"`
Tags string `json:"tags,omitempty"`
Note string `json:"note,omitempty"`
Priority string `json:"priority,omitempty"`
Alias string `json:"alias"`
Message string `json:"message"`
Description string `json:"description,omitempty"`
Details map[string]string `json:"details"`
Source string `json:"source"`
Teams []map[string]string `json:"teams,omitempty"`
Tags string `json:"tags,omitempty"`
Note string `json:"note,omitempty"`
Priority string `json:"priority,omitempty"`
}

type opsGenieCloseMessage struct {
Expand Down Expand Up @@ -835,13 +835,17 @@ func (n *OpsGenie) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
}

apiURL = n.conf.APIURL + "v2/alerts"
var teams []map[string]string
for _, t := range strings.Split(string(tmpl(n.conf.Teams)), ",") {
teams = append(teams, map[string]string{"name": t})
}
msg = &opsGenieCreateMessage{
Alias: alias,
Message: message,
Description: tmpl(n.conf.Description),
Details: details,
Source: tmpl(n.conf.Source),
Teams: tmpl(n.conf.Teams),
Teams: teams,
Tags: tmpl(n.conf.Tags),
Note: tmpl(n.conf.Note),
Priority: tmpl(n.conf.Priority),
Expand Down

0 comments on commit 291fc57

Please sign in to comment.