Skip to content

Commit

Permalink
Merge pull request elastic#341 from andrewkroh/bugfix/windows-config-…
Browse files Browse the repository at this point in the history
…path

Set a default config file location for Windows
  • Loading branch information
ruflin committed Dec 1, 2015
2 parents d4c0006 + ac4850a commit 11f04f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file based on the
### Backward Compatibility Breaks

### Bugfixes
- Fix default config file path for Windows. #341

### Added

Expand Down
10 changes: 9 additions & 1 deletion cfgfile/cfgfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"flag"
"fmt"
"io/ioutil"
"runtime"
"strings"

"gopkg.in/yaml.v2"
)
Expand All @@ -26,7 +28,13 @@ func ChangeDefaultCfgfileFlag(beatName string) error {
if cliflag == nil {
return fmt.Errorf("Flag -c not found")
}
cliflag.DefValue = fmt.Sprintf("/etc/%s/%s.yml", beatName, beatName)

if runtime.GOOS == "windows" {
cliflag.DefValue = fmt.Sprintf(`C:\Program Files\%s\%s.yml`,
strings.Title(beatName), beatName)
} else {
cliflag.DefValue = fmt.Sprintf("/etc/%s/%s.yml", beatName, beatName)
}
return cliflag.Value.Set(cliflag.DefValue)
}

Expand Down

0 comments on commit 11f04f0

Please sign in to comment.