From d46a8cf89fc5b4adc1f338ef67248302fcf790dd Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 20 Jul 2020 18:36:12 -0400 Subject: [PATCH] Allows config file to be specified with env var ND_CONFIGFILE. Fixes #415 --- conf/configuration.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conf/configuration.go b/conf/configuration.go index aa5748fc..f7e905f5 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") +}