mirror of
https://github.com/containrrr/watchtower.git
synced 2026-03-05 20:30:16 +01:00
Made the notification level flag global for all notification types.
This commit is contained in:
parent
7427b009dc
commit
24fcbe143e
5 changed files with 27 additions and 25 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package notifications
|
||||
|
||||
import (
|
||||
"github.com/johntdyer/slackrus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
|
@ -19,17 +20,24 @@ type Notifier struct {
|
|||
func NewNotifier(c *cli.Context) *Notifier {
|
||||
n := &Notifier{}
|
||||
|
||||
logLevel, err := log.ParseLevel(c.GlobalString("notifications-level"))
|
||||
if err != nil {
|
||||
log.Fatalf("Notifications invalid log level: %s", err.Error())
|
||||
}
|
||||
|
||||
acceptedLogLevels := slackrus.LevelThreshold(logLevel)
|
||||
|
||||
// Parse types and create notifiers.
|
||||
types := c.GlobalStringSlice("notifications")
|
||||
for _, t := range types {
|
||||
var tn typeNotifier
|
||||
switch t {
|
||||
case emailType:
|
||||
tn = newEmailNotifier(c)
|
||||
tn = newEmailNotifier(c, acceptedLogLevels)
|
||||
case slackType:
|
||||
tn = newSlackNotifier(c)
|
||||
tn = newSlackNotifier(c, acceptedLogLevels)
|
||||
case discordType:
|
||||
tn = newDiscordNotifier(c)
|
||||
tn = newDiscordNotifier(c, acceptedLogLevels)
|
||||
default:
|
||||
log.Fatalf("Unknown notification type %q", t)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue