mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-10 20:42:14 +00:00
The purpose is to provide a deeper, offline validation pass of the policy configuration, prior to deploying and making it live. The system behavior changes when in `--validate` mode: * Listeners, spool and spawned tasks will be silently skipped; the parameters will be validated but the primary functions of those things will be skipped silently. * After triggering the `init` event, an additional new `validate_config` event (which can be registered multiple times) will be triggered to allow lua modules to perform extended validation. * A module can either raise an error via `error` to immediately report a problem, or instead call a new, preferred, `kumo.validation_failed()` function to flag validation as failed but allow additional validation to be performed and summarized all together. * Once the `validate_config` event returns, the process will terminate with either exit code 0 for a successful validation, or non-zero to indicate that something failed. Validation errors are reported in a human readable form. This commit adds validate_config event handlers for the following helper modules: * `shaping` - any warnings reported by the underlying rust code will be reported here and cause validation to fail. This is functionally equivalent to using the `validate-shaping` binary, except that it will automatically be passed the set of shaping files defined by your `init.lua` If the `sources` helper is also configured, the list of sources referenced by the shaping config will be cross-checked against the sources data to confirm that all possible sources are defined. * `sources` - each listed source and pool will be validated by calling `kumo.make_egress_source` or `kumo.make_egress_pool` respectively. Pool membership will be validated to confirm that every listed pool is defined in the sources data. * `queues` - each domain and tenant that references an egress_pool will be cross-checked with the `sources` helper, if the sources helper has been configured. It is now an error to attempt to setup any of the above helpers more than once. refs: https://github.com/KumoCorp/kumomta/issues/211