You've already forked watchtower
							
							
				mirror of
				https://github.com/containrrr/watchtower.git
				synced 2025-10-31 00:17:44 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package notifications
 | |
| 
 | |
| import (
 | |
| 	"github.com/johntdyer/slackrus"
 | |
| 	log "github.com/sirupsen/logrus"
 | |
| 	"github.com/spf13/cobra"
 | |
| 	t "github.com/containrrr/watchtower/pkg/types"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	slackType = "slack"
 | |
| )
 | |
| 
 | |
| type slackTypeNotifier struct {
 | |
| 	slackrus.SlackrusHook
 | |
| }
 | |
| 
 | |
| func newSlackNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
 | |
| 	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:        hookURL,
 | |
| 			Username:       userName,
 | |
| 			Channel:        channel,
 | |
| 			IconEmoji:      emoji,
 | |
| 			IconURL:        iconURL,
 | |
| 			AcceptedLevels: acceptedLogLevels,
 | |
| 		},
 | |
| 	}
 | |
| 
 | |
| 	log.AddHook(n)
 | |
| 	return n
 | |
| }
 | |
| 
 | |
| func (s *slackTypeNotifier) StartNotification() {}
 | |
| 
 | |
| func (s *slackTypeNotifier) SendNotification() {}
 |