Skip to content

Commit b16659b

Browse files
stasjokmyii
authored andcommitted
fix(libmapstack): allow mapping by booleans and numbers
* Automated using myii/ssf-formula#418
1 parent 136162e commit b16659b

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

openvpn/libmapstack.jinja

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
{#- Load YAML file matching the grain/pillar/... #}
182182
{#- Fallback to use the source name as a direct filename #}
183183

184-
{%- if matcher.value | length == 0 %}
184+
{%- if matcher.value is sequence and matcher.value | length == 0 %}
185185
{#- Mangle `matcher.value` to use it as literal path #}
186186
{%- set query_parts = matcher.query.split("/") %}
187187
{%- set yaml_dirname = query_parts[0:-1] | join("/") %}
@@ -194,6 +194,11 @@
194194
{#- Some configuration return list #}
195195
{%- if yaml_names is string %}
196196
{%- set yaml_names = [yaml_names] %}
197+
{%- elif yaml_names is sequence %}
198+
{#- Convert to strings if it's a sequence of numbers #}
199+
{%- set yaml_names = yaml_names | map("string") | list %}
200+
{%- else %}
201+
{%- set yaml_names = [yaml_names | string] %}
197202
{%- endif %}
198203

199204
{#- Try to load a `.yaml.jinja` file for each `.yaml` file #}

openvpn/libmatchers.jinja

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
} %}
1313

1414
{#- When no part before `@` is provided: #}
15-
{#- - define a filename path, noted `F` #}
15+
{#- - define a YAML file path, noted `Y` #}
1616
{#- - use `salt["config.get"]`, noted `C` #}
1717
{#- - use colon `:` delimiter for querying #}
1818
{%- set _defaults = {
19-
"type": "F",
19+
"type": "Y",
2020
"query_type": "C",
2121
"query_delimiter": ":"
2222
} %}
@@ -28,11 +28,11 @@
2828
) %}
2929
{#- matcher format is `[<TYPE>[:<OPTION>[:DELIMITER]]@]<KEY>` #}
3030
{#- each matcher has a type: #}
31-
{#- - `F` to build a file name (the default when no type is set) #}
31+
{#- - `Y` to build a YAML file name (the default when no type is set) #}
3232
{#- - `C` to lookup values with `config.get` #}
3333
{#- - `G` to lookup values with `grains.get` #}
3434
{#- - `I` to lookup values with `pillar.get` #}
35-
{#- The `FILE` type option can define query type to build the file name: #}
35+
{#- The `YAML` type option can define query type to build the file name: #}
3636
{#- - `C` for query with `config.get` (the default when to query type is set) #}
3737
{#- - `G` for query with `grains.get` #}
3838
{#- - `I` for query with `pillar.get` #}

openvpn/libsaltcli.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# -*- coding: utf-8 -*-
2-
# vim: ft=jinja
1+
{#- -*- coding: utf-8 -*- #}
2+
{#- vim: ft=jinja #}
33

44
{#- Get the relevant values from the `opts` dict #}
55
{%- set opts_cli = opts.get('__cli', '') %}

0 commit comments

Comments
 (0)