From a7db22848e2cc5dc52c9b8abb180a140049dbd65 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 9 Dec 2025 19:40:46 -0500 Subject: [PATCH] fix: log environment variable configuration loading when no config file is found Signed-off-by: Deluan --- conf/configuration.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conf/configuration.go b/conf/configuration.go index 18a029255..cd24a0424 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -355,6 +355,8 @@ func Load(noConfigDump bool) { // Log configuration source if Server.ConfigFile != "" { log.Info("Loaded configuration", "file", Server.ConfigFile) + } else if hasNDEnvVars() { + log.Info("No configuration file found. Loaded configuration only from environment variables") } else { log.Warn("No configuration file found. Using default values. To specify a config file, use the --configfile flag or set the ND_CONFIGFILE environment variable.") } @@ -513,6 +515,16 @@ func AddHook(hook func()) { hooks = append(hooks, hook) } +// hasNDEnvVars checks if any ND_ prefixed environment variables are set (excluding ND_CONFIGFILE) +func hasNDEnvVars() bool { + for _, env := range os.Environ() { + if strings.HasPrefix(env, "ND_") && !strings.HasPrefix(env, "ND_CONFIGFILE=") { + return true + } + } + return false +} + func setViperDefaults() { viper.SetDefault("musicfolder", filepath.Join(".", "music")) viper.SetDefault("cachefolder", "")