Skip to content

Commit

Permalink
Add support for 'from' for hipchat notifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Walton committed Jan 15, 2016
1 parent c897ddb commit 5426fb7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ prefix: `consul-alerts/config/notifiers/hipchat/`
| key | description |
|--------------|-----------------------------------------------------|
| enabled | Enable the Hipchat notifier. [Default: false] |
| from | The name to send notifications as |
| cluster-name | The name of the cluster. [Default: "Consul Alerts"] |
| base-url | HipChat base url |
| room-id | The room to post to (mandatory) |
Expand Down
1 change: 1 addition & 0 deletions consul-alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func builtinNotifiers() []notifier.Notifier {
RoomId: hipchatConfig.RoomId,
AuthToken: hipchatConfig.AuthToken,
BaseURL: hipchatConfig.BaseURL,
From: hipchatConfig.From,
}
notifiers = append(notifiers, hipchatNotifier)
}
Expand Down
2 changes: 2 additions & 0 deletions consul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func (c *ConsulAlertClient) LoadConfig() {
valErr = loadCustomValue(&config.Notifiers.HipChat.AuthToken, val, ConfigTypeString)
case "consul-alerts/config/notifiers/hipchat/base-url":
valErr = loadCustomValue(&config.Notifiers.HipChat.BaseURL, val, ConfigTypeString)
case "consul-alerts/config/notifiers/hipchat/from":
valErr = loadCustomValue(&config.Notifiers.HipChat.From, val, ConfigTypeString)

// OpsGenie notifier config
case "consul-alerts/config/notifiers/opsgenie/enabled":
Expand Down
1 change: 1 addition & 0 deletions consul/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type HipChatNotifierConfig struct {
RoomId string
AuthToken string
BaseURL string
From string
}

type OpsGenieNotifierConfig struct {
Expand Down
7 changes: 7 additions & 0 deletions notifier/hipchat-notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type HipChatNotifier struct {
RoomId string
AuthToken string
BaseURL string
From string
}

func (notifier *HipChatNotifier) Notify(messages Messages) bool {
Expand Down Expand Up @@ -43,7 +44,13 @@ func (notifier *HipChatNotifier) Notify(messages Messages) bool {
client.BaseURL = url
}

from := ""
if notifier.From != "" {
from := notifier.From
}

notifRq := &hipchat.NotificationRequest{
From: from,
Message: text,
Color: level,
Notify: true,
Expand Down

0 comments on commit 5426fb7

Please sign in to comment.