AZURE SD: Validate HTTP config

Related-to #12810

Signed-off-by: Jayapriya Pai <janantha@redhat.com>
This commit is contained in:
Jayapriya Pai 2023-09-08 12:00:18 +05:30 committed by Jayapriya Pai
parent 7a87d0dd71
commit e44d5dfb3a
No known key found for this signature in database
GPG key ID: 36980D18029049BD
3 changed files with 16 additions and 1 deletions

View file

@ -1769,6 +1769,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",

View file

@ -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

View file

@ -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 {