config: Forbid to set a user/password without the other
This commit is contained in:
parent
41fb0f7766
commit
5e346aa9f2
1 changed files with 15 additions and 0 deletions
15
config.go
15
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")
|
labelsDir := cfg.Get("labels")
|
||||||
if labelsDir != nil {
|
if labelsDir != nil {
|
||||||
d = labelsDir.Children.Get("order")
|
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")
|
d = ntfyDir.Children.Get("access-token")
|
||||||
if d != nil {
|
if d != nil {
|
||||||
if err := d.ParseParams(&config.ntfy.AccessToken); err != 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")
|
d = amDir.Children.Get("url")
|
||||||
if d != nil {
|
if d != nil {
|
||||||
if err := d.ParseParams(&config.am.URL); err != nil {
|
if err := d.ParseParams(&config.am.URL); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue