From ff6b56c4a4e282f41ddfc8f379f95096fea0553f Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Mon, 11 Jan 2021 19:00:47 +0100 Subject: [PATCH] refactor(map): load formula configuration with `libmatchers` --- openssh/libmapstack.jinja | 319 +++++++++++++++++++++++++++++--------- openssh/map.jinja | 148 ++---------------- 2 files changed, 262 insertions(+), 205 deletions(-) diff --git a/openssh/libmapstack.jinja b/openssh/libmapstack.jinja index 9ea212b..bef5e5a 100644 --- a/openssh/libmapstack.jinja +++ b/openssh/libmapstack.jinja @@ -3,39 +3,104 @@ {#- Get the `tplroot` from `tpldir` #} {%- set tplroot = tpldir.split("/")[0] %} +{%- from tplroot ~ "/libmatchers.jinja" import parse_matchers, query_map %} + +{%- set _default_config_dirs = [ + "parameters/", + tplroot ~ "/parameters" + ] %} {%- macro mapstack( - files, + matchers, defaults=None, + dirs=_default_config_dirs, log_prefix="libmapstack: " ) %} {#- - Load YAML files in the order of `files` and merge successively the - values with `defaults` if the file exists. + Load configuration in the order of `matchers` and merge + successively the values with `defaults`. + + The `matchers` are processed using `libmatchers.jinja` to select + the configuration sources from where the values are loaded. Parameters: - - `files`: list of files to load - - `defaults`: default values to start the merging, they are - considered built-ins + - `matchers`: list of matchers in the form + `[[: