From 40ba5a72c6476fa7deb4e73a01e78530da4c45d9 Mon Sep 17 00:00:00 2001 From: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com> Date: Mon, 21 Feb 2022 10:02:02 +0000 Subject: [PATCH] fix(libmapstack): allow mapping by booleans and numbers * Automated using https://github.com/myii/ssf-formula/pull/418 --- openssh/libmapstack.jinja | 7 ++++++- openssh/libmatchers.jinja | 8 ++++---- openssh/libsaltcli.jinja | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/openssh/libmapstack.jinja b/openssh/libmapstack.jinja index 7756f0f..8f54ef3 100644 --- a/openssh/libmapstack.jinja +++ b/openssh/libmapstack.jinja @@ -181,7 +181,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("/") %} @@ -194,6 +194,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/openssh/libmatchers.jinja b/openssh/libmatchers.jinja index 6a7196f..10ff8bd 100644 --- a/openssh/libmatchers.jinja +++ b/openssh/libmatchers.jinja @@ -12,11 +12,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": ":" } %} @@ -28,11 +28,11 @@ ) %} {#- matcher format is `[[: