mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
add slackrus slack notifications
This commit is contained in:
parent
d989254b1a
commit
fd7f8a40ed
6 changed files with 95 additions and 10 deletions
38
notifications/slack.go
Normal file
38
notifications/slack.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package notifications
|
||||
|
||||
import (
|
||||
"github.com/johntdyer/slackrus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
const (
|
||||
slackType = "slack"
|
||||
)
|
||||
|
||||
type slackTypeNotifier struct {
|
||||
slackrus.SlackrusHook
|
||||
}
|
||||
|
||||
func newSlackNotifier(c *cli.Context) typeNotifier {
|
||||
logLevel, err := log.ParseLevel(c.GlobalString("notification-slack-level"))
|
||||
if err != nil {
|
||||
log.Fatalf("Slack notifications: %s", err.Error())
|
||||
}
|
||||
|
||||
n := &slackTypeNotifier{
|
||||
SlackrusHook: slackrus.SlackrusHook{
|
||||
HookURL: c.GlobalString("notification-slack-hook-url"),
|
||||
Username: c.GlobalString("notification-slack-identifier"),
|
||||
AcceptedLevels: slackrus.LevelThreshold(logLevel),
|
||||
},
|
||||
}
|
||||
|
||||
log.AddHook(n)
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *slackTypeNotifier) StartNotification() {}
|
||||
|
||||
func (s *slackTypeNotifier) SendNotification() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue