Changeset

13217:b264ea91e930 0.12

util.prosodyctl.check: Validate format of module list options Should detect things like misplaced settings inside modules_enabled
author Kim Alvefur <zash@zash.se>
date Mon, 17 Jul 2023 14:45:15 +0200
parents 13216:fcc052ca1652
children 13218:e576c6a0d1f8 13219:22763b30e458
files util/prosodyctl/check.lua
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/prosodyctl/check.lua	Mon Jul 17 14:03:13 2023 +0200
+++ b/util/prosodyctl/check.lua	Mon Jul 17 14:45:15 2023 +0200
@@ -496,6 +496,34 @@
 			print();
 		end
 
+		local function validate_module_list(host, name, modules)
+			if modules == nil then
+				return -- okay except for global section, checked separately
+			end
+			local t = type(modules)
+			if t ~= "table" then
+				print("    The " .. name .. " in the " .. host .. " section should not be a " .. t .. " but a list of strings, e.g.");
+				print("    " .. name .. " = { \"name_of_module\", \"another_plugin\", }")
+				print()
+				ok = false
+				return
+			end
+			for k, v in pairs(modules) do
+				if type(k) ~= "number" or type(v) ~= "string" then
+					print("    The " .. name .. " in the " .. host .. " section should not be a map of " .. type(k) .. " to " .. type(v)
+									.. " but a list of strings, e.g.");
+					print("    " .. name .. " = { \"name_of_module\", \"another_plugin\", }")
+					ok = false
+					break
+				end
+			end
+		end
+
+		for host, options in enabled_hosts() do
+			validate_module_list(host, "modules_enabled", options.modules_enabled);
+			validate_module_list(host, "modules_disabled", options.modules_disabled);
+		end
+
 		do -- Check for modules enabled both normally and as components
 			local modules = global:get_option_set("modules_enabled");
 			for host, options in enabled_hosts() do