summaryrefslogtreecommitdiffstats
path: root/aconf/model
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-03-10 21:11:19 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-03-11 16:54:19 +0200
commit31bd7bd491738d8653a9e181594969a3665aca22 (patch)
treeb8710c5554c89bd698520fa3f2b80ef1faf454f1 /aconf/model
parent2d58b8f49ec03fe3d4ad843085ffe09880e3f888 (diff)
downloadaconf-31bd7bd491738d8653a9e181594969a3665aca22.tar.bz2
aconf-31bd7bd491738d8653a9e181594969a3665aca22.tar.xz
persistence: move augeas back-end directives out of addresses
Diffstat (limited to 'aconf/model')
-rw-r--r--aconf/model/field.lua8
-rw-r--r--aconf/model/root.lua20
2 files changed, 24 insertions, 4 deletions
diff --git a/aconf/model/field.lua b/aconf/model/field.lua
index f5382c4..6e4607f 100644
--- a/aconf/model/field.lua
+++ b/aconf/model/field.lua
@@ -158,7 +158,12 @@ end
function M.Field:topology(context)
return {
- {path=context.path, addr=context.addr, type=self.dtype}
+ {
+ path=context.path,
+ addr=context.addr,
+ be_mode=self.be_mode,
+ type=self.dtype
+ }
}
end
@@ -332,6 +337,7 @@ end
function M.TreeNode:topology(context)
local res = super(self, M.TreeNode):topology(context)
+ res[1].subtype = res[1].type
res[1].type = 'table'
util.extend(res, node.topology(self:load(context, {create=true})))
return res
diff --git a/aconf/model/root.lua b/aconf/model/root.lua
index 2a135f2..a407b07 100644
--- a/aconf/model/root.lua
+++ b/aconf/model/root.lua
@@ -71,14 +71,28 @@ function M.register(name, field, params)
for _, record in ipairs(node.topology(root:fetch(name))) do
local top = M.topology(record.addr, true)
- local function set(k, v)
- setdefault(top, k, v)
- assert(top[k] == v)
+ local function set(k, v, t)
+ if not t then t = top end
+ setdefault(t, k, v)
+ assert(t[k] == v)
end
set('type', record.type)
+ set('subtype', record.subtype)
table.insert(top.paths, record.path)
+ local mode = record.be_mode
+ if mode then
+ if object.isinstance(
+ mode, require('aconf.path.address.special').SpecialMode
+ ) then
+ mode = {['.']=mode}
+ end
+ for addr, m in pairs(mode) do
+ set('mode', m, addr == '.' and top or top(addr, true))
+ end
+ end
+
if record.scope then
local scope = node.addr(
root:fetch(pth.to_absolute(record.scope, pth.parent(record.path)))