Use environment variables to locate Program Files on Windows (#6317)
This commit is contained in:
committed by
Daniel Nelson
parent
9f612fd52d
commit
08b903a646
@@ -641,7 +641,11 @@ func getDefaultConfigPath() (string, error) {
|
||||
homefile := os.ExpandEnv("${HOME}/.telegraf/telegraf.conf")
|
||||
etcfile := "/etc/telegraf/telegraf.conf"
|
||||
if runtime.GOOS == "windows" {
|
||||
etcfile = `C:\Program Files\Telegraf\telegraf.conf`
|
||||
programFiles := os.Getenv("ProgramFiles")
|
||||
if programFiles == "" { // Should never happen
|
||||
programFiles = `C:\Program Files`
|
||||
}
|
||||
etcfile = programFiles + `\Telegraf\telegraf.conf`
|
||||
}
|
||||
for _, path := range []string{envfile, homefile, etcfile} {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user