From: Vsevolod Stakhov Date: Tue, 18 Nov 2025 09:22:35 +0000 (+0000) Subject: [Minor] Migrate rules/controller/maps.lua to lua_shape X-Git-Tag: 3.14.1~11^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86cc5913a998c2a3e2091dff40ea3f913709c5de;p=thirdparty%2Frspamd.git [Minor] Migrate rules/controller/maps.lua to lua_shape Replace tableshape with lua_shape in controller maps plugin. Changes: - ts.shape { ... } → T.table({ ... }) - ts.array_of(x) → T.array(x) - :is_optional() → :optional() - Added documentation to all fields and schema Schema: query_json_schema for validating map query requests with optional maps filter and report_misses flag. --- diff --git a/rules/controller/maps.lua b/rules/controller/maps.lua index 718e292f69..d640cbc99c 100644 --- a/rules/controller/maps.lua +++ b/rules/controller/maps.lua @@ -18,7 +18,7 @@ limitations under the License. local maps_cache local maps_aliases local lua_util = require "lua_util" -local ts = require("tableshape").types +local T = require "lua_shape.core" local ucl = require "ucl" local function maybe_fill_maps_cache() @@ -142,11 +142,11 @@ local function handle_list_maps(_, conn, _) } end -local query_json_schema = ts.shape { - maps = ts.array_of(ts.string):is_optional(), - report_misses = ts.boolean:is_optional(), - values = ts.array_of(ts.string), -} +local query_json_schema = T.table({ + maps = T.array(T.string()):optional():doc({ summary = "List of map names to query" }), + report_misses = T.boolean():optional():doc({ summary = "Report keys that do not match" }), + values = T.array(T.string()):doc({ summary = "Values to check against maps" }), +}):doc({ summary = "Query multiple maps with given values" }) local function handle_query_json(task, conn) maybe_fill_maps_cache()