Browse Source

change config names to files for consistency

pull/1686/head
Ali Reza 9 years ago
parent
commit
c81b4e8a87
  1. 6
      config/config.go
  2. 4
      config/config_test.go
  3. 4
      config/testdata/conf.good.yml
  4. 2
      retrieval/discovery/file.go
  5. 2
      retrieval/discovery/file_test.go

6
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)
}

4
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),
},
},

4
config/testdata/conf.good.yml vendored

@ -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:

2
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),
}
}

2
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 (

Loading…
Cancel
Save