Refactored policy structure
Previously, all modules in an org were fully copied into that org. Now, the only copy of the modules is at modpol.modules, and orgs have a policy table at [org].policies, which overrides the config table in any given module.
This commit is contained in:
@ -19,26 +19,30 @@ display_policies.config = {
|
||||
-- @param result Callback if this module is embedded in other modules
|
||||
function display_policies:initiate(result)
|
||||
local display_table = {}
|
||||
for k,v in pairs(self.org.modules) do
|
||||
local input = v.name
|
||||
table.insert(display_table, input)
|
||||
if v.config
|
||||
and modpol.util.num_pairs(v.config) > 0 then
|
||||
for k2,v2 in pairs(v.config) do
|
||||
local v2_string = ""
|
||||
if type(v2) == "string" then
|
||||
v2_string = v2
|
||||
elseif type(v2) == "table"
|
||||
or type(v2) == "number" then
|
||||
v2_string = tostring(v2)
|
||||
else
|
||||
v2_string = "Could not render"
|
||||
for k,v in pairs(self.org.policies) do
|
||||
if v then -- check the module is allowed
|
||||
local input = modpol.modules[k].name
|
||||
table.insert(display_table, input)
|
||||
if modpol.modules[k].config then
|
||||
for k2,v2 in pairs(modpol.modules[k].config) do
|
||||
if self.org.policies[k][k2] then
|
||||
v2 = self.org.policies[k][k2]
|
||||
end
|
||||
local v2_string = ""
|
||||
if type(v2) == "string" then
|
||||
v2_string = v2
|
||||
elseif type(v2) == "table"
|
||||
or type(v2) == "number" then
|
||||
v2_string = tostring(v2)
|
||||
else
|
||||
v2_string = "Could not render"
|
||||
end
|
||||
input = k2..": "..v2_string
|
||||
table.insert(display_table, input)
|
||||
end
|
||||
input = k2..": "..v2_string
|
||||
table.insert(display_table, input)
|
||||
end
|
||||
table.insert(display_table, "---")
|
||||
end
|
||||
table.insert(display_table, "---")
|
||||
end
|
||||
local output = table.concat(display_table,"\n")
|
||||
if #display_table == 0 then
|
||||
|
Reference in New Issue
Block a user