From 108f671519917265d197d38b71206970a5c7192e Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 22 Mar 2025 17:08:03 -0400 Subject: [PATCH] fix(server): don't break if the ND_CONFIGFILE does not exist Signed-off-by: Deluan --- conf/configuration.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/conf/configuration.go b/conf/configuration.go index bc4b7edca..4fab95da7 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -596,9 +596,17 @@ func InitConfig(cfgFile string) { } } +// getConfigFile returns the path to the config file, either from the flag or from the environment variable. +// If it is defined in the environment variable, it will check if the file exists. func getConfigFile(cfgFile string) string { if cfgFile != "" { return cfgFile } - return os.Getenv("ND_CONFIGFILE") + cfgFile = os.Getenv("ND_CONFIGFILE") + if cfgFile != "" { + if _, err := os.Stat(cfgFile); err == nil { + return cfgFile + } + } + return "" }