diff --git a/config/config.go b/config/config.go index 3190291ba..7ecf313a7 100644 --- a/config/config.go +++ b/config/config.go @@ -604,7 +604,7 @@ func (c *DNSSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // FileSDConfig is the configuration for file based discovery. type FileSDConfig struct { - Names []string `yaml:"names"` + Files []string `yaml:"files"` RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"` // Catches all undefined fields and must be empty after parsing. @@ -619,10 +619,10 @@ func (c *FileSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err != nil { return err } - if len(c.Names) == 0 { + if len(c.Files) == 0 { return fmt.Errorf("file service discovery config must contain at least one path name") } - for _, name := range c.Names { + for _, name := range c.Files { if !patFileSDName.MatchString(name) { return fmt.Errorf("path name %q is not valid for file discovery", name) } diff --git a/config/config_test.go b/config/config_test.go index 476f143b1..f125c55c5 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -72,11 +72,11 @@ var expectedConf = &Config{ FileSDConfigs: []*FileSDConfig{ { - Names: []string{"foo/*.slow.json", "foo/*.slow.yml", "single/file.yml"}, + Files: []string{"foo/*.slow.json", "foo/*.slow.yml", "single/file.yml"}, RefreshInterval: model.Duration(10 * time.Minute), }, { - Names: []string{"bar/*.yaml"}, + Files: []string{"bar/*.yaml"}, RefreshInterval: model.Duration(5 * time.Minute), }, }, diff --git a/config/testdata/conf.good.yml b/config/testdata/conf.good.yml index f2cc1bd0e..a28fc2029 100644 --- a/config/testdata/conf.good.yml +++ b/config/testdata/conf.good.yml @@ -24,12 +24,12 @@ scrape_configs: # scheme defaults to 'http'. file_sd_configs: - - names: + - files: - foo/*.slow.json - foo/*.slow.yml - single/file.yml refresh_interval: 10m - - names: + - files: - bar/*.yaml target_groups: diff --git a/retrieval/discovery/file.go b/retrieval/discovery/file.go index 9aedb1605..40034944a 100644 --- a/retrieval/discovery/file.go +++ b/retrieval/discovery/file.go @@ -49,7 +49,7 @@ type FileDiscovery struct { // NewFileDiscovery returns a new file discovery for the given paths. func NewFileDiscovery(conf *config.FileSDConfig) *FileDiscovery { return &FileDiscovery{ - paths: conf.Names, + paths: conf.Files, interval: time.Duration(conf.RefreshInterval), } } diff --git a/retrieval/discovery/file_test.go b/retrieval/discovery/file_test.go index 1f8b19487..10ff49dba 100644 --- a/retrieval/discovery/file_test.go +++ b/retrieval/discovery/file_test.go @@ -37,7 +37,7 @@ func testFileSD(t *testing.T, ext string) { // As interval refreshing is more of a fallback, we only want to test // whether file watches work as expected. var conf config.FileSDConfig - conf.Names = []string{"fixtures/_*" + ext} + conf.Files = []string{"fixtures/_*" + ext} conf.RefreshInterval = model.Duration(1 * time.Hour) var (