mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-15 14:40:13 +01:00
switch urfave to cobra
This commit is contained in:
parent
339df55cc6
commit
998e8052c5
10 changed files with 581 additions and 398 deletions
|
|
@ -3,7 +3,7 @@ package notifications
|
|||
import (
|
||||
"github.com/johntdyer/slackrus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -14,20 +14,27 @@ type slackTypeNotifier struct {
|
|||
slackrus.SlackrusHook
|
||||
}
|
||||
|
||||
func newSlackNotifier(c *cli.Context, acceptedLogLevels []log.Level) typeNotifier {
|
||||
func newSlackNotifier(c *cobra.Command, acceptedLogLevels []log.Level) typeNotifier {
|
||||
flags := c.PersistentFlags()
|
||||
|
||||
hookUrl, _ := flags.GetString("notification-slack-hook-url")
|
||||
userName, _ := flags.GetString("notification-slack-identifier")
|
||||
channel, _ := flags.GetString("notification-slack-channel")
|
||||
emoji, _ := flags.GetString("notification-slack-icon-emoji")
|
||||
iconUrl, _ := flags.GetString("notification-slack-icon-url")
|
||||
|
||||
n := &slackTypeNotifier{
|
||||
SlackrusHook: slackrus.SlackrusHook{
|
||||
HookURL: c.GlobalString("notification-slack-hook-url"),
|
||||
Username: c.GlobalString("notification-slack-identifier"),
|
||||
Channel: c.GlobalString("notification-slack-channel"),
|
||||
IconEmoji: c.GlobalString("notification-slack-icon-emoji"),
|
||||
IconURL: c.GlobalString("notification-slack-icon-url"),
|
||||
HookURL: hookUrl,
|
||||
Username: userName,
|
||||
Channel: channel,
|
||||
IconEmoji: emoji,
|
||||
IconURL: iconUrl,
|
||||
AcceptedLevels: acceptedLogLevels,
|
||||
},
|
||||
}
|
||||
|
||||
log.AddHook(n)
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue