Skip to content

Commit

Permalink
Merge pull request prometheus#12785 from roidelapluie/validate-sd-config
Browse files Browse the repository at this point in the history
HTTP SD: Validate HTTP config
  • Loading branch information
roidelapluie authored Sep 7, 2023
2 parents f711d71 + 8498b96 commit 7a87d0d
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 @@ -1857,6 +1857,10 @@ var expectedErrors = []struct {
filename: "http_url_no_host.bad.yml",
errMsg: "host is missing in URL",
},
{
filename: "http_token_file.bad.yml",
errMsg: "at most one of bearer_token & bearer_token_file must be configured",
},
{
filename: "http_url_bad_scheme.bad.yml",
errMsg: "URL scheme must be 'http' or 'https'",
Expand Down
6 changes: 6 additions & 0 deletions config/testdata/http_token_file.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scrape_configs:
- job_name: foo
http_sd_configs:
- url: http://foo
bearer_token: foo
bearer_token_file: foo
2 changes: 1 addition & 1 deletion discovery/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if parsedURL.Host == "" {
return fmt.Errorf("host is missing in URL")
}
return nil
return c.HTTPClientConfig.Validate()
}

const httpSDURLLabel = model.MetaLabelPrefix + "url"
Expand Down

0 comments on commit 7a87d0d

Please sign in to comment.