Fix missing unmarshal for Marathon SD config.

This commit is contained in:
Robert Jacob 2015-09-02 15:08:37 +02:00 committed by Fabian Reinartz
parent 852dfd99e2
commit 847072514e
4 changed files with 40 additions and 0 deletions

View file

@ -626,6 +626,10 @@ type KubernetesSDConfig struct {
func (c *MarathonSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = DefaultMarathonSDConfig
type plain MarathonSDConfig
err := unmarshal((*plain)(c))
if err != nil {
return err
}
if len(c.Servers) == 0 {
return fmt.Errorf("Marathon SD config must contain at least one Marathon server")
}

View file

@ -206,6 +206,24 @@ var expectedConf = &Config{
},
},
},
{
JobName: "service-marathon",
ScrapeInterval: Duration(15 * time.Second),
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
MetricsPath: DefaultScrapeConfig.MetricsPath,
Scheme: DefaultScrapeConfig.Scheme,
MarathonSDConfigs: []*MarathonSDConfig{
{
Servers: []string{
"http://marathon.example.com:8080",
},
RefreshInterval: Duration(30 * time.Second),
},
},
},
},
original: "",
}
@ -281,6 +299,9 @@ var expectedErrors = []struct {
}, {
filename: "bearertoken_basicauth.bad.yml",
errMsg: "at most one of basic_auth, bearer_token & bearer_token_file must be configured",
}, {
filename: "marathon_no_servers.bad.yml",
errMsg: "Marathon SD config must contain at least one Marathon server",
},
}

View file

@ -107,3 +107,8 @@ scrape_configs:
- 'https://localhost:1234'
username: 'myusername'
password: 'mypassword'
- job_name: service-marathon
marathon_sd_configs:
- servers:
- 'http://marathon.example.com:8080'

View file

@ -0,0 +1,10 @@
# my global config
global:
scrape_interval: 15s
evaluation_interval: 30s
scrape_configs:
- job_name: service-marathon
marathon_sd_configs:
- servers: