2024-09-05 16:40:47 +01:00
|
|
|
|
|
|
|
|
local components = import "components.jsonnet";
|
|
|
|
|
|
|
|
|
|
local apply = function(p, components)
|
|
|
|
|
|
2024-11-05 21:17:34 +00:00
|
|
|
local base = {
|
2024-09-05 16:40:47 +01:00
|
|
|
|
|
|
|
|
with:: function(k, v) self + {
|
|
|
|
|
[k]:: v
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
with_params:: function(pars)
|
|
|
|
|
self + std.foldl(
|
|
|
|
|
function(obj, par) obj.with(par.key, par.value),
|
|
|
|
|
std.objectKeysValues(pars),
|
|
|
|
|
self
|
|
|
|
|
),
|
|
|
|
|
|
2024-11-05 21:17:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
local component = base + components[p.name];
|
|
|
|
|
|
|
|
|
|
component.with_params(p.parameters);
|
2024-09-05 16:40:47 +01:00
|
|
|
|
|
|
|
|
local decode = function(config)
|
|
|
|
|
local add = function(state, c) state + apply(c, components);
|
|
|
|
|
local patterns = std.foldl(add, config, {});
|
|
|
|
|
patterns;
|
|
|
|
|
|
|
|
|
|
decode
|
|
|
|
|
|