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.
watchtower/pkg/notifications/slack.go

47 lines
1.1 KiB
Go

package notifications
import (
t "github.com/containrrr/watchtower/pkg/types"
"github.com/johntdyer/slackrus"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
const (
slackType = "slack"
)
type slackTypeNotifier struct {
slackrus.SlackrusHook
}
func newSlackNotifier(_ *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
hookURL := viper.GetString("notification-slack-hook-url")
userName := viper.GetString("notification-slack-identifier")
channel := viper.GetString("notification-slack-channel")
emoji := viper.GetString("notification-slack-icon-emoji")
iconURL := viper.GetString("notification-slack-icon-url")
n := &slackTypeNotifier{
SlackrusHook: slackrus.SlackrusHook{
HookURL: hookURL,
Username: userName,
Channel: channel,
IconEmoji: emoji,
IconURL: iconURL,
AcceptedLevels: acceptedLogLevels,
},
}
log.AddHook(n)
return n
}
func (s *slackTypeNotifier) StartNotification() {}
func (s *slackTypeNotifier) SendNotification() {}
func (s *slackTypeNotifier) Close() {}