You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
7 years ago
|
package notifications
|
||
|
|
||
|
import (
|
||
5 years ago
|
t "github.com/containrrr/watchtower/pkg/types"
|
||
7 years ago
|
"github.com/johntdyer/slackrus"
|
||
|
log "github.com/sirupsen/logrus"
|
||
6 years ago
|
"github.com/spf13/cobra"
|
||
7 years ago
|
)
|
||
|
|
||
|
const (
|
||
|
slackType = "slack"
|
||
|
)
|
||
|
|
||
|
type slackTypeNotifier struct {
|
||
|
slackrus.SlackrusHook
|
||
|
}
|
||
|
|
||
5 years ago
|
func newSlackNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
|
||
6 years ago
|
flags := c.PersistentFlags()
|
||
|
|
||
5 years ago
|
hookURL, _ := flags.GetString("notification-slack-hook-url")
|
||
6 years ago
|
userName, _ := flags.GetString("notification-slack-identifier")
|
||
5 years ago
|
channel, _ := flags.GetString("notification-slack-channel")
|
||
|
emoji, _ := flags.GetString("notification-slack-icon-emoji")
|
||
|
iconURL, _ := flags.GetString("notification-slack-icon-url")
|
||
6 years ago
|
|
||
7 years ago
|
n := &slackTypeNotifier{
|
||
|
SlackrusHook: slackrus.SlackrusHook{
|
||
6 years ago
|
HookURL: hookURL,
|
||
6 years ago
|
Username: userName,
|
||
|
Channel: channel,
|
||
|
IconEmoji: emoji,
|
||
6 years ago
|
IconURL: iconURL,
|
||
7 years ago
|
AcceptedLevels: acceptedLogLevels,
|
||
7 years ago
|
},
|
||
|
}
|
||
|
|
||
|
log.AddHook(n)
|
||
|
return n
|
||
|
}
|
||
|
|
||
|
func (s *slackTypeNotifier) StartNotification() {}
|
||
|
|
||
|
func (s *slackTypeNotifier) SendNotification() {}
|