From 796ca08bd33c80a857e60a97696a9e973837821e Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Thu, 17 Feb 2022 10:04:01 +0000 Subject: [PATCH] feat(template): review PRs 243, 244, 245 & 246 * https://github.com/saltstack-formulas/template-formula/pull/243 * https://github.com/saltstack-formulas/template-formula/pull/244 * https://github.com/saltstack-formulas/template-formula/pull/245 * https://github.com/saltstack-formulas/template-formula/pull/246 Closes #417. --- ssf/files/default/formula/libmapstack.jinja | 7 ++++++- ssf/files/default/formula/libmatchers.jinja | 8 ++++---- ssf/files/default/formula/libsaltcli.jinja | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ssf/files/default/formula/libmapstack.jinja b/ssf/files/default/formula/libmapstack.jinja index 2d6d64c2..070679c5 100644 --- a/ssf/files/default/formula/libmapstack.jinja +++ b/ssf/files/default/formula/libmapstack.jinja @@ -196,7 +196,7 @@ {#- Load YAML file matching the grain/pillar/... #} {#- Fallback to use the source name as a direct filename #} -{%- if matcher.value | length == 0 %} +{%- if matcher.value is sequence and matcher.value | length == 0 %} {#- Mangle `matcher.value` to use it as literal path #} {%- set query_parts = matcher.query.split("/") %} {%- set yaml_dirname = query_parts[0:-1] | join("/") %} @@ -209,6 +209,11 @@ {#- Some configuration return list #} {%- if yaml_names is string %} {%- set yaml_names = [yaml_names] %} +{%- elif yaml_names is sequence %} +{#- Convert to strings if it's a sequence of numbers #} +{%- set yaml_names = yaml_names | map("string") | list %} +{%- else %} +{%- set yaml_names = [yaml_names | string] %} {%- endif %} {#- Try to load a `.yaml.jinja` file for each `.yaml` file #} diff --git a/ssf/files/default/formula/libmatchers.jinja b/ssf/files/default/formula/libmatchers.jinja index b2f2c498..643edbc5 100644 --- a/ssf/files/default/formula/libmatchers.jinja +++ b/ssf/files/default/formula/libmatchers.jinja @@ -27,11 +27,11 @@ } %} {#- When no part before `@` is provided: #} -{#- - define a filename path, noted `F` #} +{#- - define a YAML file path, noted `Y` #} {#- - use `salt["config.get"]`, noted `C` #} {#- - use colon `:` delimiter for querying #} {%- set _defaults = { - "type": "F", + "type": "Y", "query_type": "C", "query_delimiter": ":" } %} @@ -43,11 +43,11 @@ ) %} {#- matcher format is `[[: