mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
fix(shoutrrr): make shoutrrr init failure a fatal error (#561)
also writes out any (unlikely) errors from template.Execute instead of ignoring
This commit is contained in:
parent
52300804d2
commit
1081f3c24c
2 changed files with 5 additions and 6 deletions
|
@ -47,10 +47,8 @@ func NewNotifier(c *cobra.Command) *Notifier {
|
|||
default:
|
||||
log.Fatalf("Unknown notification type %q", t)
|
||||
}
|
||||
if tn != nil {
|
||||
n.types = append(n.types, tn)
|
||||
}
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ func newShoutrrrNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Noti
|
|||
urls, _ := flags.GetStringArray("notification-url")
|
||||
r, err := shoutrrr.CreateSender(urls...)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to initialize Shoutrrr notifications: %s\n", err.Error())
|
||||
return nil
|
||||
log.Fatalf("Failed to initialize Shoutrrr notifications: %s\n", err.Error())
|
||||
}
|
||||
|
||||
n := &shoutrrrTypeNotifier{
|
||||
|
@ -50,7 +49,9 @@ func newShoutrrrNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Noti
|
|||
|
||||
func (e *shoutrrrTypeNotifier) buildMessage(entries []*log.Entry) string {
|
||||
var body bytes.Buffer
|
||||
e.template.Execute(&body, entries)
|
||||
if err := e.template.Execute(&body, entries); err != nil {
|
||||
fmt.Printf("Failed to execute Shoutrrrr template: %s\n", err.Error())
|
||||
}
|
||||
|
||||
return body.String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue