EC2 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 11:46:03 +05:30
parent 7a87d0dd71
commit 7f085aeb6a
No known key found for this signature in database
GPG key ID: 5ED742D95C787611
3 changed files with 11 additions and 1 deletions

View file

@ -1745,6 +1745,10 @@ var expectedErrors = []struct {
filename: "ec2_filters_empty_values.bad.yml",
errMsg: `EC2 SD configuration filter values cannot be empty`,
},
{
filename: "ec2_token_file.bad.yml",
errMsg: `at most one of bearer_token & bearer_token_file must be configured`,
},
{
filename: "section_key_dup.bad.yml",
errMsg: "field scrape_configs already set in type config.plain",

View file

@ -0,0 +1,6 @@
scrape_configs:
- job_name: foo
ec2_sd_configs:
- region: us-east-1
bearer_token: foo
bearer_token_file: foo

View file

@ -129,7 +129,7 @@ func (c *EC2SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return errors.New("EC2 SD configuration filter values cannot be empty")
}
}
return nil
return c.HTTPClientConfig.Validate()
}
// EC2Discovery periodically performs EC2-SD requests. It implements