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:
Nathan Schneider
2022-02-09 22:14:26 -07:00
parent f950b5b94c
commit 2028f1ee85
7 changed files with 76 additions and 52 deletions

View File

@ -15,7 +15,7 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
local index = #self.processes + 1
local module = self.modules[module_slug]
local module = modpol.modules[module_slug]
-- first applies any relevant org policies
-- then overrides with the config values given on input
@ -23,6 +23,11 @@ function modpol.orgs:call_module(module_slug, initiator, config, result, parent_
if modpol.util.num_pairs(module.config) > 0 then
for k, v in pairs(module.config) do
new_config[k] = v
-- overrides with org policies
if self.policies[module_slug]
and self.policies[module_slug][k] then
new_config[k] = self.policies[module_slug][k]
end
-- overrides with input settings
if config and config[k] then
new_config[k] = config[k]