EC2 SD: Validate HTTP config

Related-to #12810

Signed-off-by: Jayapriya Pai <janantha@redhat.com>
pull/12811/head
Jayapriya Pai 2 years ago
parent 7a87d0dd71
commit 7f085aeb6a
No known key found for this signature in database
GPG Key ID: 5ED742D95C787611
  1. 4
      config/config_test.go
  2. 6
      config/testdata/ec2_token_file.bad.yml
  3. 2
      discovery/aws/ec2.go

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

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

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

Loading…
Cancel
Save