Diff

util/startup.lua @ 13743:0c7e11c11968 13.0

core.configmanager: Remove dependency on 'prosody' global for Credential Minimizing dependencies on global state is nice, as it makes using configmanager outside of Prosody easier.
author Kim Alvefur <zash@zash.se>
date Sat, 22 Feb 2025 00:00:41 +0100
parent 13659:5abdcad8c2e0
line wrap: on
line diff
--- a/util/startup.lua	Mon Feb 17 23:06:06 2025 +0000
+++ b/util/startup.lua	Sat Feb 22 00:00:41 2025 +0100
@@ -89,6 +89,14 @@
 		end
 	end
 	prosody.config_file = filename
+	local credentials_directory = os.getenv("CREDENTIALS_DIRECTORY");
+	if credentials_directory then
+		config.set_credentials_directory(credentials_directory);
+	elseif prosody.process_type == "prosody" then
+		config.set_credential_fallback_mode("error");
+	else
+		config.set_credential_fallback_mode("warn");
+	end
 	local ok, level, err = config.load(filename);
 	if not ok then
 		print("\n");
@@ -271,7 +279,6 @@
 		config = CFG_CONFIGDIR or ".";
 		plugins = CFG_PLUGINDIR or "plugins";
 		data = "data";
-		credentials = os.getenv("CREDENTIALS_DIRECTORY");
 	};
 
 	prosody.arg = _G.arg;