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

@ -14,7 +14,7 @@ function temp_org()
return {
id = nil,
name = nil,
modules = modpol.util.copy_table(modpol.modules),
policies = {},
processes = {},
pending = {},
members = {},
@ -105,6 +105,9 @@ function modpol.orgs.init_instance()
local instance = temp_org()
instance.id = 1
instance.name = "Root"
for i,v in pairs(modpol.modules) do
instance.policies[i] = {}
end
setmetatable(instance, modpol.orgs)
@ -183,7 +186,7 @@ function modpol.orgs:add_org(name, user)
child_org.name = name
child_org.parent = self.id
child_org.processes = {}
child_org.modules = modpol.util.copy_table(self.modules)
child_org.policies = modpol.util.copy_table(self.policies)
setmetatable(child_org, modpol.orgs)