mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
Update Shoutrrr to v0.4 (#810)
This commit is contained in:
parent
60a6300f0e
commit
738215a1f7
10 changed files with 244 additions and 166 deletions
|
|
@ -1,12 +1,11 @@
|
|||
package notifications
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
shoutrrrTeams "github.com/containrrr/shoutrrr/pkg/services/teams"
|
||||
t "github.com/containrrr/watchtower/pkg/types"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -20,11 +19,11 @@ type msTeamsTypeNotifier struct {
|
|||
}
|
||||
|
||||
// NewMsTeamsNotifier is a factory method creating a new teams notifier instance
|
||||
func NewMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) t.ConvertableNotifier {
|
||||
func NewMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) t.ConvertibleNotifier {
|
||||
return newMsTeamsNotifier(cmd, acceptedLogLevels)
|
||||
}
|
||||
|
||||
func newMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) t.ConvertableNotifier {
|
||||
func newMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) t.ConvertibleNotifier {
|
||||
|
||||
flags := cmd.PersistentFlags()
|
||||
|
||||
|
|
@ -43,26 +42,19 @@ func newMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) t.Con
|
|||
return n
|
||||
}
|
||||
|
||||
func (n *msTeamsTypeNotifier) GetURL() string {
|
||||
|
||||
baseURL := "https://outlook.office.com/webhook/"
|
||||
|
||||
path := strings.Replace(n.webHookURL, baseURL, "", 1)
|
||||
rawToken := strings.Replace(path, "/IncomingWebhook", "", 1)
|
||||
token := strings.Split(rawToken, "/")
|
||||
config := &shoutrrrTeams.Config{
|
||||
Token: shoutrrrTeams.Token{
|
||||
A: token[0],
|
||||
B: token[1],
|
||||
C: token[2],
|
||||
},
|
||||
func (n *msTeamsTypeNotifier) GetURL() (string, error) {
|
||||
webhookURL, err := url.Parse(n.webHookURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return config.GetURL().String()
|
||||
}
|
||||
config, err := shoutrrrTeams.ConfigFromWebhookURL(*webhookURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
func (n *msTeamsTypeNotifier) StartNotification() {}
|
||||
func (n *msTeamsTypeNotifier) SendNotification() {}
|
||||
func (n *msTeamsTypeNotifier) Close() {}
|
||||
func (n *msTeamsTypeNotifier) Levels() []log.Level { return nil }
|
||||
func (n *msTeamsTypeNotifier) Fire(entry *log.Entry) error { return nil }
|
||||
config.Color = ColorHex
|
||||
config.Title = GetTitle()
|
||||
|
||||
return config.GetURL().String(), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue