Allows config file to be specified with env var ND_CONFIGFILE. Fixes #415
This commit is contained in:
@@ -103,6 +103,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func InitConfig(cfgFile string) {
|
func InitConfig(cfgFile string) {
|
||||||
|
cfgFile = getConfigFile(cfgFile)
|
||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
// Use config file from the flag.
|
// Use config file from the flag.
|
||||||
viper.SetConfigFile(cfgFile)
|
viper.SetConfigFile(cfgFile)
|
||||||
@@ -122,3 +123,10 @@ func InitConfig(cfgFile string) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getConfigFile(cfgFile string) string {
|
||||||
|
if cfgFile != "" {
|
||||||
|
return cfgFile
|
||||||
|
}
|
||||||
|
return os.Getenv("ND_CONFIGFILE")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user