Skip to content
Snippets Groups Projects
Commit c9563cde authored by kb-light's avatar kb-light Committed by Matthias Schiffer
Browse files

scripts: check_site_lib: introduce need_string_array_match() (#1016)

parent 1fdaee08
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ local function check_branch(k, _) ...@@ -8,7 +8,7 @@ local function check_branch(k, _)
need_string(prefix .. 'name') need_string(prefix .. 'name')
need_string_array(prefix .. 'mirrors') need_string_array(prefix .. 'mirrors')
need_number(prefix .. 'good_signatures') need_number(prefix .. 'good_signatures')
need_string_array(prefix .. 'pubkeys') need_string_array_match(prefix .. 'pubkeys', '^%x+$')
end end
need_table('autoupdater.branches', check_branch) need_table('autoupdater.branches', check_branch)
...@@ -41,7 +41,7 @@ end ...@@ -41,7 +41,7 @@ end
need_boolean('poe_passthrough', false) need_boolean('poe_passthrough', false)
if need_table('dns', nil, false) then if need_table('dns', nil, false) then
need_number('dns.cacheentries', false) need_number('dns.cacheentries', false)
need_string_array('dns.servers', false) need_string_array_match('dns.servers', '^[%x:]+$', false)
end end
if need_table('next_node', nil, false) then if need_table('next_node', nil, false) then
......
...@@ -138,6 +138,12 @@ function need_string_array(varname, required) ...@@ -138,6 +138,12 @@ function need_string_array(varname, required)
return var return var
end end
function need_string_array_match(varname, pat, required)
local ok, var = pcall(need_array, varname, function(e) assert(e:match(pat)) end, required)
assert(ok, "site.conf error: expected `" .. varname .. "' to be a string array matching pattern `" .. pat .. "'")
return var
end
function need_array_of(varname, array, required) function need_array_of(varname, array, required)
local ok, var = pcall(need_array, varname, function(e) assert_one_of(e, array) end,required) local ok, var = pcall(need_array, varname, function(e) assert_one_of(e, array) end,required)
assert(ok, "site.conf error: expected `" .. varname .. "' to be a subset of given array: " .. array_to_string(array)) assert(ok, "site.conf error: expected `" .. varname .. "' to be a subset of given array: " .. array_to_string(array))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment