Skip to content

Commit

Permalink
EC2 SD: Validate HTTP config
Browse files Browse the repository at this point in the history
Related-to prometheus#12810

Signed-off-by: Jayapriya Pai <janantha@redhat.com>
  • Loading branch information
slashpai committed Sep 8, 2023
1 parent 7a87d0d commit 7f085ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions config/testdata/ec2_token_file.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scrape_configs:
- job_name: foo
ec2_sd_configs:
- region: us-east-1
bearer_token: foo
bearer_token_file: foo
2 changes: 1 addition & 1 deletion discovery/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f085ae

Please sign in to comment.