From 925c86ea698c68f684ba1645a58c88d688e6acc5 Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Mon, 11 Jan 2021 17:41:20 +0100 Subject: [PATCH] refactor(map): compound matchers like parsing with `libmatchers` --- openssh/libmatchers.jinja | 208 ++++++++++++++++++++++++++++++++++++++ openssh/map.jinja | 137 ++++++------------------- 2 files changed, 240 insertions(+), 105 deletions(-) create mode 100644 openssh/libmatchers.jinja diff --git a/openssh/libmatchers.jinja b/openssh/libmatchers.jinja new file mode 100644 index 0000000..b5e768d --- /dev/null +++ b/openssh/libmatchers.jinja @@ -0,0 +1,208 @@ +{#- -*- coding: utf-8 -*- #} +{#- vim: ft=jinja #} + +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split("/")[0] %} +{%- from tplroot ~ "/libsaltcli.jinja" import cli %} + +{%- set query_map = { + "C": "config.get", + "G": "grains.get", + "I": "pillar.get", + } %} + +{#- When no part before `@` is provided: #} +{#- - define a filename path, noted `F` #} +{#- - use `salt["config.get"]`, noted `C` #} +{%- set _defaults = { + "type": "F", + "query_type": "C", + } %} + +{%- macro parse_matchers( + matchers, + config_get_strategy=None, + log_prefix="libmatchers: " + ) %} +{#- matcher format is `[[: