aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_maps.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-27 11:28:38 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-27 16:54:45 +0100
commit9a2122307a5f776a03def8198da5045a0818bc94 (patch)
tree66c7820310b2d473fce397ef25560d5b16c05c45 /lualib/lua_maps.lua
parent50466eddf26c21c999eb2065c49072e6012922a3 (diff)
downloadrspamd-9a2122307a5f776a03def8198da5045a0818bc94.tar.gz
rspamd-9a2122307a5f776a03def8198da5045a0818bc94.zip
[Minor] Maps: Export maps schema
Diffstat (limited to 'lualib/lua_maps.lua')
-rw-r--r--lualib/lua_maps.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua
index 6b478ded8..094494dca 100644
--- a/lualib/lua_maps.lua
+++ b/lualib/lua_maps.lua
@@ -20,6 +20,7 @@ limitations under the License.
]]--
local rspamd_logger = require "rspamd_logger"
+local ts = require("tableshape").types
local exports = {}
@@ -315,4 +316,24 @@ end
exports.rspamd_maybe_check_map = rspamd_maybe_check_map
+exports.map_schema = ts.one_of{
+ ts.string, -- 'http://some_map'
+ ts.array_of(ts.string), -- ['foo', 'bar']
+ ts.shape{ -- complex object
+ name = ts.string:is_optional(),
+ description = ts.string:is_optional(),
+ timeout = ts.number,
+ data = ts.array_of(ts.string):is_optional(),
+ -- Tableshape has no options support for something like key1 or key2?
+ upstreams = ts.one_of{
+ ts.string,
+ ts.array_of(ts.string),
+ }:is_optional(),
+ url = ts.one_of{
+ ts.string,
+ ts.array_of(ts.string),
+ }:is_optional(),
+ }
+}
+
return exports