Fix from discussion

Signed-off-by: Mikhail Fesenko <proggga@gmail.com>
This commit is contained in:
Mikhail Fesenko 2023-07-13 00:52:27 +02:00
parent 17cdfdd79f
commit 02e11cc2a7
No known key found for this signature in database
GPG Key ID: EFF13E9E31D0464E
1 changed files with 5 additions and 7 deletions

View File

@ -107,15 +107,13 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return errors.New("marathon_sd: at most one of auth_token & auth_token_file must be configured")
}
isAuthTokenProvided := len(c.AuthToken) > 0 || len(c.AuthTokenFile) > 0
if isAuthTokenProvided {
if c.HTTPClientConfig.BasicAuth != nil {
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")
}
if len(c.HTTPClientConfig.BearerToken) > 0 || len(c.HTTPClientConfig.BearerTokenFile) > 0 {
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")
}
if c.HTTPClientConfig.Authorization != nil {
case c.HTTPClientConfig.Authorization != nil:
return errors.New("marathon_sd: at most one of auth_token, auth_token_file & authorization must be configured")
}
}