]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Migrate rules/controller/maps.lua to lua_shape
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 18 Nov 2025 09:22:35 +0000 (09:22 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 18 Nov 2025 09:22:35 +0000 (09:22 +0000)
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.

rules/controller/maps.lua

index 718e292f690be8425ddbd27235e3a6f1edb0f0e4..d640cbc99c2b9cf128fdd632b36551c95b2516f4 100644 (file)
@@ -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()