mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
fix(notifier): don't panic on unconfigured notifier (#869)
This commit is contained in:
parent
3b60afe553
commit
b644ec6829
2 changed files with 22 additions and 0 deletions
|
|
@ -55,6 +55,12 @@ func (n *Notifier) String() string {
|
||||||
sb.WriteString(", ")
|
sb.WriteString(", ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sb.Len() < 2 {
|
||||||
|
// No notification services are configured, return early as the separator strip is not applicable
|
||||||
|
return "none"
|
||||||
|
}
|
||||||
|
|
||||||
names := sb.String()
|
names := sb.String()
|
||||||
|
|
||||||
// remove the last separator
|
// remove the last separator
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,22 @@ func TestActions(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("notifications", func() {
|
var _ = Describe("notifications", func() {
|
||||||
|
Describe("the notifier", func() {
|
||||||
|
When("only empty notifier types are provided", func() {
|
||||||
|
|
||||||
|
command := cmd.NewRootCommand()
|
||||||
|
flags.RegisterNotificationFlags(command)
|
||||||
|
|
||||||
|
err := command.ParseFlags([]string{
|
||||||
|
"--notifications",
|
||||||
|
"shoutrrr",
|
||||||
|
})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
notif := notifications.NewNotifier(command)
|
||||||
|
|
||||||
|
Expect(notif.String()).To(Equal("none"))
|
||||||
|
})
|
||||||
|
})
|
||||||
Describe("the slack notifier", func() {
|
Describe("the slack notifier", func() {
|
||||||
builderFn := notifications.NewSlackNotifier
|
builderFn := notifications.NewSlackNotifier
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue