diff --git a/conf/configuration.go b/conf/configuration.go index aa5748fcc..f7e905f54 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -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") +}