if not override then
return def
end
+ if not def then
+ return override
+ end
for k,v in pairs(override) do
- if k ~= 'selector' and k ~= 'backend' then
- if def[k] then
- if type(v) == 'table' then
- override_defaults(def[k], v)
- else
- def[k] = v
- end
+ if def[k] then
+ if type(v) == 'table' then
+ def[k] = override_defaults(def[k], v)
else
def[k] = v
end
+ else
+ def[k] = v
end
end
+
+ return def
+end
+
+local function is_implicit(t)
+ local mt = getmetatable(t)
+
+ return mt and mt.class and mt.class == 'ucl.type.impl_array'
end
local function metric_pairs(t)
-- collect the keys
local keys = {}
- local mt = getmetatable(t)
- local implicit_array = mt and mt.class and mt.class == 'ucl.type.impl_array'
+ local implicit_array = is_implicit(t)
local function gen_keys(tbl)
if implicit_array then
-- group {name = "foo" ... } + group "blah" { ... }
for gr_name,gr in pairs(v) do
if type(gr_name) ~= 'number' then
- table.insert(keys, {gr_name, gr})
+ -- We can also have implicit arrays here
+ local gr_implicit = is_implicit(gr)
+
+ if gr_implicit then
+ for _,gr_elt in ipairs(gr) do
+ table.insert(keys, {gr_name, gr_elt})
+ end
+ else
+ table.insert(keys, {gr_name, gr})
+ end
end
end
end
else
for k,v in pairs(tbl) do
if type(k) ~= 'number' then
- table.insert(keys, {k, v})
+ -- We can also have implicit arrays here
+ local is_implicit = is_implicit(v)
+
+ if is_implicit then
+ for _,elt in ipairs(v) do
+ table.insert(keys, {k, elt})
+ end
+ else
+ table.insert(keys, {k, v})
+ end
end
end
end
if not cfg.group then cfg.group = {} end
if cfg.group[k] then
- local merged = override_defaults(new_group, cfg.group[k])
- cfg.group[k] = merged
+ cfg.group[k] = override_defaults(cfg.group[k], new_group)
else
cfg.group[k] = new_group
end
local function convert_metric(cfg, metric)
if metric.actions then
- cfg.actions = override_defaults(metric.actions)
+ cfg.actions = override_defaults(cfg.actions, metric.actions)
logger.warnx("overriding actions from the legacy metric settings")
end
if metric.unknown_weight then