aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_cfg_utils.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-08-07 13:32:48 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-08-07 13:32:48 +0100
commit890e7fe0e079b946c34986f5c65fbd05626486d0 (patch)
tree20011a3b973ee26e5907fccc9137744fe2f60711 /lualib/lua_cfg_utils.lua
parentf1e53832fb37f2cf059b74139ce5de1dffc82651 (diff)
downloadrspamd-890e7fe0e079b946c34986f5c65fbd05626486d0.tar.gz
rspamd-890e7fe0e079b946c34986f5c65fbd05626486d0.zip
[Feature] Check for plugin configuration errors on `configtest`
Diffstat (limited to 'lualib/lua_cfg_utils.lua')
-rw-r--r--lualib/lua_cfg_utils.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lualib/lua_cfg_utils.lua b/lualib/lua_cfg_utils.lua
index 141b497bc..e07a3ae05 100644
--- a/lualib/lua_cfg_utils.lua
+++ b/lualib/lua_cfg_utils.lua
@@ -19,6 +19,7 @@ limitations under the License.
-- This module contains utility functions for configuration of Rspamd modules
--]]
+local rspamd_logger = require "rspamd_logger"
local exports = {}
--[[[
@@ -64,4 +65,20 @@ exports.push_config_error = function(module, err)
table.insert(rspamd_plugins_state.config_errors[module], err)
end
+exports.check_configuration_errors = function()
+ local ret = true
+
+ if type(rspamd_plugins_state.config_errors) == 'table' then
+ -- We have some errors found during the configuration, so we need to show them
+ for m, errs in pairs(rspamd_plugins_state.config_errors) do
+ for _, err in ipairs(errs) do
+ rspamd_logger.errx(rspamd_config, 'configuration error: module %s: %s', m, err)
+ ret = false
+ end
+ end
+ end
+
+ return ret
+end
+
return exports \ No newline at end of file