Merge pull request #1686 from alileza/master

change file_sd names to files, for consistency
This commit is contained in:
Fabian Reinartz 2016-06-01 07:49:34 -07:00
commit 9e952a55c6
5 changed files with 9 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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

View File

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