Skip to content

Commit e19845c

Browse files
committed
Load config directory using filepath.Walk
closes influxdata#1137
1 parent 5213455 commit e19845c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [#1751](https://github.com/influxdata/telegraf/issues/1751): Fix powerdns integer parse error handling.
3838
- [#1752](https://github.com/influxdata/telegraf/issues/1752): Fix varnish plugin defaults not being used.
3939
- [#1517](https://github.com/influxdata/telegraf/issues/1517): Fix windows glob paths.
40+
- [#1137](https://github.com/influxdata/telegraf/issues/1137): Fix issue loading config directory on windows.
4041

4142
## v1.0.1 [unreleased]
4243

internal/config/config.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,24 +404,21 @@ func PrintOutputConfig(name string) error {
404404
}
405405

406406
func (c *Config) LoadDirectory(path string) error {
407-
directoryEntries, err := ioutil.ReadDir(path)
408-
if err != nil {
409-
return err
410-
}
411-
for _, entry := range directoryEntries {
412-
if entry.IsDir() {
413-
continue
407+
walkfn := func(thispath string, info os.FileInfo, _ error) error {
408+
if info.IsDir() {
409+
return nil
414410
}
415-
name := entry.Name()
411+
name := info.Name()
416412
if len(name) < 6 || name[len(name)-5:] != ".conf" {
417-
continue
413+
return nil
418414
}
419-
err := c.LoadConfig(filepath.Join(path, name))
415+
err := c.LoadConfig(thispath)
420416
if err != nil {
421417
return err
422418
}
419+
return nil
423420
}
424-
return nil
421+
return filepath.Walk(path, walkfn)
425422
}
426423

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

0 commit comments

Comments
 (0)