mirror of https://github.com/prometheus/prometheus
maraphon.go: Simplified conditions in method
Signed-off-by: Mikhail Fesenko <proggga@gmail.com>pull/11463/head
parent
162612ea86
commit
17cdfdd79f
|
@ -106,15 +106,19 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
if len(c.AuthToken) > 0 && len(c.AuthTokenFile) > 0 {
|
if len(c.AuthToken) > 0 && len(c.AuthTokenFile) > 0 {
|
||||||
return errors.New("marathon_sd: at most one of auth_token & auth_token_file must be configured")
|
return errors.New("marathon_sd: at most one of auth_token & auth_token_file must be configured")
|
||||||
}
|
}
|
||||||
if c.HTTPClientConfig.BasicAuth != nil && (len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0) {
|
|
||||||
|
isAuthTokenProvided := len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0
|
||||||
|
if isAuthTokenProvided {
|
||||||
|
if c.HTTPClientConfig.BasicAuth != nil {
|
||||||
return errors.New("marathon_sd: at most one of basic_auth, auth_token & auth_token_file must be configured")
|
return errors.New("marathon_sd: at most one of basic_auth, auth_token & auth_token_file must be configured")
|
||||||
}
|
}
|
||||||
if (len(c.HTTPClientConfig.BearerToken) > 0 || len(c.HTTPClientConfig.BearerTokenFile) > 0) && (len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0) {
|
if len(c.HTTPClientConfig.BearerToken) > 0 || len(c.HTTPClientConfig.BearerTokenFile) > 0 {
|
||||||
return errors.New("marathon_sd: at most one of bearer_token, bearer_token_file, auth_token & auth_token_file must be configured")
|
return errors.New("marathon_sd: at most one of bearer_token, bearer_token_file, auth_token & auth_token_file must be configured")
|
||||||
}
|
}
|
||||||
if c.HTTPClientConfig.Authorization != nil && (len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0) {
|
if c.HTTPClientConfig.Authorization != nil {
|
||||||
return errors.New("marathon_sd: at most one of auth_token, auth_token_file & authorization must be configured")
|
return errors.New("marathon_sd: at most one of auth_token, auth_token_file & authorization must be configured")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return c.HTTPClientConfig.Validate()
|
return c.HTTPClientConfig.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue