From 480f4c8ccbe34acec873cead28b60d15edec9524 Mon Sep 17 00:00:00 2001 From: Maximilian Brandau Date: Mon, 23 Mar 2020 14:42:17 +0100 Subject: [PATCH] reuse router --- pkg/notifications/shoutrrr.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/notifications/shoutrrr.go b/pkg/notifications/shoutrrr.go index 869ce54..108e3b6 100644 --- a/pkg/notifications/shoutrrr.go +++ b/pkg/notifications/shoutrrr.go @@ -3,6 +3,7 @@ package notifications import ( "fmt" "github.com/containrrr/shoutrrr" + "github.com/containrrr/shoutrrr/pkg/router" t "github.com/containrrr/watchtower/pkg/types" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -15,6 +16,7 @@ const ( // Implements Notifier, logrus.Hook type shoutrrrTypeNotifier struct { Urls []string + Router *router.ServiceRouter entries []*log.Entry logLevels []log.Level } @@ -23,9 +25,11 @@ func newShoutrrrNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Noti flags := c.PersistentFlags() urls, _ := flags.GetStringArray("notification-url") + r, _ := shoutrrr.CreateSender(urls...) n := &shoutrrrTypeNotifier{ Urls: urls, + Router: r, logLevels: acceptedLogLevels, } @@ -48,8 +52,7 @@ func (e *shoutrrrTypeNotifier) sendEntries(entries []*log.Entry) { // Do the sending in a separate goroutine so we don't block the main process. msg := e.buildMessage(entries) go func() { - router, _ := shoutrrr.CreateSender(e.Urls...) - errs := router.Send(msg, nil) + errs := e.Router.Send(msg, nil) for i, err := range errs { if err != nil {