mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #11463 from proggga/small_refactor
marathon.go: Simplified conditions in method
This commit is contained in:
commit
ea039fcebf
|
@ -106,14 +106,16 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
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")
|
||||
}
|
||||
if c.HTTPClientConfig.BasicAuth != nil && (len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0) {
|
||||
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) {
|
||||
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) {
|
||||
return errors.New("marathon_sd: at most one of auth_token, auth_token_file & authorization must be configured")
|
||||
|
||||
if len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0 {
|
||||
switch {
|
||||
case c.HTTPClientConfig.BasicAuth != nil:
|
||||
return errors.New("marathon_sd: at most one of basic_auth, auth_token & auth_token_file must be configured")
|
||||
case 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")
|
||||
case c.HTTPClientConfig.Authorization != nil:
|
||||
return errors.New("marathon_sd: at most one of auth_token, auth_token_file & authorization must be configured")
|
||||
}
|
||||
}
|
||||
return c.HTTPClientConfig.Validate()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue