Mercurial > prosody-hg
comparison util/prosodyctl/check.lua @ 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 | fcc052ca1652 |
| children | e576c6a0d1f8 22763b30e458 |
comparison
equal
deleted
inserted
replaced
| 13216:fcc052ca1652 | 13217:b264ea91e930 |
|---|---|
| 494 print(" "..tostring(suggested_global_modules / function (x) return ("%q"):format(x) end)); | 494 print(" "..tostring(suggested_global_modules / function (x) return ("%q"):format(x) end)); |
| 495 end | 495 end |
| 496 print(); | 496 print(); |
| 497 end | 497 end |
| 498 | 498 |
| 499 local function validate_module_list(host, name, modules) | |
| 500 if modules == nil then | |
| 501 return -- okay except for global section, checked separately | |
| 502 end | |
| 503 local t = type(modules) | |
| 504 if t ~= "table" then | |
| 505 print(" The " .. name .. " in the " .. host .. " section should not be a " .. t .. " but a list of strings, e.g."); | |
| 506 print(" " .. name .. " = { \"name_of_module\", \"another_plugin\", }") | |
| 507 print() | |
| 508 ok = false | |
| 509 return | |
| 510 end | |
| 511 for k, v in pairs(modules) do | |
| 512 if type(k) ~= "number" or type(v) ~= "string" then | |
| 513 print(" The " .. name .. " in the " .. host .. " section should not be a map of " .. type(k) .. " to " .. type(v) | |
| 514 .. " but a list of strings, e.g."); | |
| 515 print(" " .. name .. " = { \"name_of_module\", \"another_plugin\", }") | |
| 516 ok = false | |
| 517 break | |
| 518 end | |
| 519 end | |
| 520 end | |
| 521 | |
| 522 for host, options in enabled_hosts() do | |
| 523 validate_module_list(host, "modules_enabled", options.modules_enabled); | |
| 524 validate_module_list(host, "modules_disabled", options.modules_disabled); | |
| 525 end | |
| 526 | |
| 499 do -- Check for modules enabled both normally and as components | 527 do -- Check for modules enabled both normally and as components |
| 500 local modules = global:get_option_set("modules_enabled"); | 528 local modules = global:get_option_set("modules_enabled"); |
| 501 for host, options in enabled_hosts() do | 529 for host, options in enabled_hosts() do |
| 502 local component_module = options.component_module; | 530 local component_module = options.component_module; |
| 503 if component_module and modules:contains(component_module) then | 531 if component_module and modules:contains(component_module) then |
