Skip to content

Commit

Permalink
Load config directory using filepath.Walk
Browse files Browse the repository at this point in the history
closes #1137
  • Loading branch information
sparrc committed Sep 28, 2016
1 parent 5213455 commit e19845c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [#1751](https://github.com/influxdata/telegraf/issues/1751): Fix powerdns integer parse error handling.
- [#1752](https://github.com/influxdata/telegraf/issues/1752): Fix varnish plugin defaults not being used.
- [#1517](https://github.com/influxdata/telegraf/issues/1517): Fix windows glob paths.
- [#1137](https://github.com/influxdata/telegraf/issues/1137): Fix issue loading config directory on windows.

## v1.0.1 [unreleased]

Expand Down
19 changes: 8 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,21 @@ func PrintOutputConfig(name string) error {
}

func (c *Config) LoadDirectory(path string) error {
directoryEntries, err := ioutil.ReadDir(path)
if err != nil {
return err
}
for _, entry := range directoryEntries {
if entry.IsDir() {
continue
walkfn := func(thispath string, info os.FileInfo, _ error) error {
if info.IsDir() {
return nil
}
name := entry.Name()
name := info.Name()
if len(name) < 6 || name[len(name)-5:] != ".conf" {
continue
return nil
}
err := c.LoadConfig(filepath.Join(path, name))
err := c.LoadConfig(thispath)
if err != nil {
return err
}
return nil
}
return nil
return filepath.Walk(path, walkfn)
}

// Try to find a default config file at these locations (in order):
Expand Down

0 comments on commit e19845c

Please sign in to comment.