Browse Source

Merge pull request #12812 from slashpai/azure

AZURE SD: Validate HTTP config
pull/12709/head
Julien Pivotto 1 year ago committed by GitHub
parent
commit
75470ba815
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      config/config_test.go
  2. 11
      config/testdata/azure_bearertoken_basicauth.bad.yml
  3. 2
      discovery/azure/azure.go

4
config/config_test.go

@ -1773,6 +1773,10 @@ var expectedErrors = []struct {
filename: "azure_authentication_method.bad.yml",
errMsg: "unknown authentication_type \"invalid\". Supported types are \"OAuth\" or \"ManagedIdentity\"",
},
{
filename: "azure_bearertoken_basicauth.bad.yml",
errMsg: "at most one of basic_auth, oauth2, bearer_token & bearer_token_file must be configured",
},
{
filename: "empty_scrape_config.bad.yml",
errMsg: "empty or null scrape config section",

11
config/testdata/azure_bearertoken_basicauth.bad.yml vendored

@ -0,0 +1,11 @@
scrape_configs:
- job_name: prometheus
azure_sd_configs:
- subscription_id: 11AAAA11-A11A-111A-A111-1111A1111A11
tenant_id: BBBB222B-B2B2-2B22-B222-2BB2222BB2B2
client_id: 333333CC-3C33-3333-CCC3-33C3CCCCC33C
client_secret: mysecret
bearer_token: 1234
basic_auth:
username: user
password: password

2
discovery/azure/azure.go

@ -144,7 +144,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return fmt.Errorf("unknown authentication_type %q. Supported types are %q or %q", c.AuthenticationMethod, authMethodOAuth, authMethodManagedIdentity)
}
return nil
return c.HTTPClientConfig.Validate()
}
type Discovery struct {

Loading…
Cancel
Save