diff --git a/cmd/backup/config.go b/cmd/backup/config.go index 5510bb2..850909c 100644 --- a/cmd/backup/config.go +++ b/cmd/backup/config.go @@ -240,6 +240,11 @@ func (c *Config) resolve() (reset func() error, warnings []string, err error) { return } + if _, ok := hookLevels[c.NotificationLevel]; !ok { + err = errwrap.Wrap(nil, fmt.Sprintf("unknown NOTIFICATION_LEVEL %s", c.NotificationLevel)) + return + } + if c.BackupFilenameExpand { c.BackupFilename = os.ExpandEnv(c.BackupFilename) c.BackupLatestSymlink = os.ExpandEnv(c.BackupLatestSymlink) diff --git a/cmd/backup/script.go b/cmd/backup/script.go index c82bfd5..797ae90 100644 --- a/cmd/backup/script.go +++ b/cmd/backup/script.go @@ -78,12 +78,7 @@ func (s *script) init() error { return nil }) // Register notifications first so they can fire in case of other init errors. - - hookLevel, ok := hookLevels[s.c.NotificationLevel] - if !ok { - return errwrap.Wrap(nil, fmt.Sprintf("unknown NOTIFICATION_LEVEL %s", s.c.NotificationLevel)) - } - s.hookLevel = hookLevel + s.hookLevel = hookLevels[s.c.NotificationLevel] if len(s.c.NotificationURLs) > 0 { sender, senderErr := shoutrrr.CreateSender(s.c.NotificationURLs...)