Allows config file to be specified with env var ND_CONFIGFILE. Fixes #415

This commit is contained in:
Deluan 2020-07-20 18:36:12 -04:00
parent 7e81a3b895
commit d46a8cf89f
1 changed files with 8 additions and 0 deletions

View File

@ -103,6 +103,7 @@ func init() {
}
func InitConfig(cfgFile string) {
cfgFile = getConfigFile(cfgFile)
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
@ -122,3 +123,10 @@ func InitConfig(cfgFile string) {
os.Exit(1)
}
}
func getConfigFile(cfgFile string) string {
if cfgFile != "" {
return cfgFile
}
return os.Getenv("ND_CONFIGFILE")
}