mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
config: fix Kubernetes config with empty API server (#5256)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
362873f72b
commit
e72c875e63
|
@ -632,6 +632,11 @@ func TestLoadConfigRuleFilesAbsolutePath(t *testing.T) {
|
||||||
testutil.Equals(t, ruleFilesExpectedConf, c)
|
testutil.Equals(t, ruleFilesExpectedConf, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestKubernetesEmptyAPIServer(t *testing.T) {
|
||||||
|
_, err := LoadFile("testdata/kubernetes_empty_apiserver.good.yml")
|
||||||
|
testutil.Ok(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
var expectedErrors = []struct {
|
var expectedErrors = []struct {
|
||||||
filename string
|
filename string
|
||||||
errMsg string
|
errMsg string
|
||||||
|
|
4
config/testdata/kubernetes_empty_apiserver.good.yml
vendored
Normal file
4
config/testdata/kubernetes_empty_apiserver.good.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: prometheus
|
||||||
|
kubernetes_sd_configs:
|
||||||
|
- role: endpoints
|
|
@ -1,6 +1,5 @@
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: prometheus
|
- job_name: prometheus
|
||||||
|
|
||||||
kubernetes_sd_configs:
|
kubernetes_sd_configs:
|
||||||
- role: pod
|
- role: pod
|
||||||
bearer_token: 1234
|
bearer_token: 1234
|
||||||
|
|
|
@ -107,7 +107,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c.APIServer.URL == nil && !reflect.DeepEqual(c.HTTPClientConfig, &config_util.HTTPClientConfig{}) {
|
if c.APIServer.URL == nil && !reflect.DeepEqual(c.HTTPClientConfig, config_util.HTTPClientConfig{}) {
|
||||||
return fmt.Errorf("to use custom HTTP client configuration please provide the 'api_server' URL explicitly")
|
return fmt.Errorf("to use custom HTTP client configuration please provide the 'api_server' URL explicitly")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue