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)
|
||||
}
|
||||
|
||||
func TestKubernetesEmptyAPIServer(t *testing.T) {
|
||||
_, err := LoadFile("testdata/kubernetes_empty_apiserver.good.yml")
|
||||
testutil.Ok(t, err)
|
||||
}
|
||||
|
||||
var expectedErrors = []struct {
|
||||
filename 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:
|
||||
- job_name: prometheus
|
||||
|
||||
kubernetes_sd_configs:
|
||||
- role: pod
|
||||
bearer_token: 1234
|
||||
|
|
|
@ -107,7 +107,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
if err != nil {
|
||||
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 nil
|
||||
|
|
Loading…
Reference in a new issue