Added basic policy backend for modules. Also added confirmation in CLI to call a module. At that confirmation, the relevant policies are shown. Still need to create a module for changing policies and to add more configuration options to existing policies.
This commit is contained in:
@ -15,11 +15,12 @@ function temp_org()
|
||||
id = nil,
|
||||
name = nil,
|
||||
modules = modpol.util.copy_table(modpol.modules),
|
||||
policies = {},
|
||||
processes = {},
|
||||
pending = {},
|
||||
members = {},
|
||||
parent = nil,
|
||||
children = {}
|
||||
children = {},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -18,12 +18,22 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
|
||||
local module = modpol.modules[module_slug]
|
||||
|
||||
-- sets default values for undeclared config variables
|
||||
if modpol.util.num_pairs(module.config) > 0 and config then
|
||||
for k, v in pairs(module.config) do
|
||||
if config[k] == nil then
|
||||
config[k] = v
|
||||
end
|
||||
end
|
||||
-- first applies any relevant org policies
|
||||
-- then overrides with the config values given on input
|
||||
local new_config = {}
|
||||
if modpol.util.num_pairs(module.config) > 0 then
|
||||
for k, v in pairs(module.config) do
|
||||
new_config[k] = v
|
||||
-- org policies
|
||||
if self.policies[module_slug]
|
||||
and self.policies[module_slug][k] then
|
||||
new_config[k] = self.policies[module_slug][k]
|
||||
end
|
||||
-- input settings
|
||||
if config and config[k] then
|
||||
new_config[k] = config[k]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- setting default params
|
||||
@ -34,7 +44,7 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
|
||||
id = index,
|
||||
parent_id = parent_id,
|
||||
children = {},
|
||||
config = config,
|
||||
config = modpol.util.copy_table(new_config),
|
||||
data = modpol.util.copy_table(module.data),
|
||||
slug = module_slug
|
||||
}
|
||||
|
Reference in New Issue
Block a user