mirror of
https://github.com/prometheus/prometheus.git
synced 2025-12-08 19:11:02 +01:00
Merge pull request #12785 from roidelapluie/validate-sd-config
HTTP SD: Validate HTTP config
This commit is contained in:
commit
7a87d0dd71
@ -1857,6 +1857,10 @@ var expectedErrors = []struct {
|
|||||||
filename: "http_url_no_host.bad.yml",
|
filename: "http_url_no_host.bad.yml",
|
||||||
errMsg: "host is missing in URL",
|
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",
|
filename: "http_url_bad_scheme.bad.yml",
|
||||||
errMsg: "URL scheme must be 'http' or 'https'",
|
errMsg: "URL scheme must be 'http' or 'https'",
|
||||||
|
|||||||
6
config/testdata/http_token_file.bad.yml
vendored
Normal file
6
config/testdata/http_token_file.bad.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
scrape_configs:
|
||||||
|
- job_name: foo
|
||||||
|
http_sd_configs:
|
||||||
|
- url: http://foo
|
||||||
|
bearer_token: foo
|
||||||
|
bearer_token_file: foo
|
||||||
@ -99,7 +99,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
if parsedURL.Host == "" {
|
if parsedURL.Host == "" {
|
||||||
return fmt.Errorf("host is missing in URL")
|
return fmt.Errorf("host is missing in URL")
|
||||||
}
|
}
|
||||||
return nil
|
return c.HTTPClientConfig.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
const httpSDURLLabel = model.MetaLabelPrefix + "url"
|
const httpSDURLLabel = model.MetaLabelPrefix + "url"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user