Add ability to configure channel, username, icon emoji/url in slack cfg
This commit is contained in:
parent
05b54687b6
commit
dcce0076ee
|
@ -16,6 +16,10 @@ import (
|
||||||
type PluginConfig struct {
|
type PluginConfig struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Webhook string `yaml:"webhook"`
|
Webhook string `yaml:"webhook"`
|
||||||
|
Channel string `yaml:"channel"`
|
||||||
|
Username string `yaml:"username"`
|
||||||
|
IconEmoji string `yaml:"icon_emoji"`
|
||||||
|
IconURL string `yaml:"icon_url"`
|
||||||
LogLevel *string `yaml:"log_level"`
|
LogLevel *string `yaml:"log_level"`
|
||||||
}
|
}
|
||||||
type Notify struct {
|
type Notify struct {
|
||||||
|
@ -43,8 +47,12 @@ func (n *Notify) Notify(ctx context.Context, notification *protobufs.Notificatio
|
||||||
logger.Info(fmt.Sprintf("found notify signal for %s config", notification.Name))
|
logger.Info(fmt.Sprintf("found notify signal for %s config", notification.Name))
|
||||||
logger.Debug(fmt.Sprintf("posting to %s webhook, message %s", cfg.Webhook, notification.Text))
|
logger.Debug(fmt.Sprintf("posting to %s webhook, message %s", cfg.Webhook, notification.Text))
|
||||||
|
|
||||||
err := slack.PostWebhookContext(ctx, n.ConfigByName[notification.Name].Webhook, &slack.WebhookMessage{
|
err := slack.PostWebhookContext(ctx, cfg.Webhook, &slack.WebhookMessage{
|
||||||
Text: notification.Text,
|
Text: notification.Text,
|
||||||
|
Channel: cfg.Channel,
|
||||||
|
Username: cfg.Username,
|
||||||
|
IconEmoji: cfg.IconEmoji,
|
||||||
|
IconURL: cfg.IconURL,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err.Error())
|
logger.Error(err.Error())
|
||||||
|
|
|
@ -28,6 +28,12 @@ format: |
|
||||||
|
|
||||||
webhook: <WEBHOOK_URL>
|
webhook: <WEBHOOK_URL>
|
||||||
|
|
||||||
|
# API request data as defined by the Slack webhook API.
|
||||||
|
channel: <CHANNEL_NAME>
|
||||||
|
username: <USERNAME>
|
||||||
|
icon_emoji: <ICON_EMOJI>
|
||||||
|
icon_url: <ICON_URL>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# type: slack
|
# type: slack
|
||||||
|
|
Loading…
Reference in a new issue