diff --git a/config.go b/config.go index c4d0109..cde14b6 100644 --- a/config.go +++ b/config.go @@ -134,6 +134,11 @@ func readConfig(path string) (*config, error) { } } + if (config.Password != "" && config.User == "") || + (config.Password == "" && config.User != "") { + return nil, errors.New("user and password have to be set together") + } + labelsDir := cfg.Get("labels") if labelsDir != nil { d = labelsDir.Children.Get("order") @@ -214,6 +219,11 @@ func readConfig(path string) (*config, error) { } } + if (config.ntfy.Password != "" && config.ntfy.User == "") || + (config.ntfy.Password == "" && config.ntfy.User != "") { + return nil, errors.New("ntfy: user and password have to be set together") + } + d = ntfyDir.Children.Get("access-token") if d != nil { if err := d.ParseParams(&config.ntfy.AccessToken); err != nil { @@ -291,6 +301,11 @@ func readConfig(path string) (*config, error) { } } + if (config.am.Password != "" && config.am.User == "") || + (config.am.Password == "" && config.am.User != "") { + return nil, errors.New("alertmanager: user and password have to be set together") + } + d = amDir.Children.Get("url") if d != nil { if err := d.ParseParams(&config.am.URL); err != nil {