mirror of
https://github.com/saltstack-formulas/template-formula.git
synced 2025-04-17 10:10:28 +00:00
fix(libtofs): don't crash if “tofs.files_switch” lookup a list
We need to process all elements when the “config.get” lookup of “tofs.files_switch” return a list. * template/libtofs.jinja: force the output of the lookup to be a list.
This commit is contained in:
parent
13f1728c27
commit
0979d359fd
1 changed files with 16 additions and 9 deletions
|
@ -83,18 +83,25 @@
|
|||
{%- for fs in fsl %}
|
||||
{%- for src_file in src_files %}
|
||||
{%- if fs %}
|
||||
{%- set fs_dir = salt['config.get'](fs, fs) %}
|
||||
{%- set fs_dirs = salt['config.get'](fs, fs) %}
|
||||
{%- else %}
|
||||
{%- set fs_dir = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
|
||||
{%- set fs_dirs = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
|
||||
{%- endif %}
|
||||
{%- set url = [
|
||||
'- salt:/',
|
||||
path_prefix_inc_ext.strip('/'),
|
||||
files_dir.strip('/'),
|
||||
fs_dir.strip('/'),
|
||||
src_file.strip('/'),
|
||||
] | select | join('/') %}
|
||||
{#- Force the `config.get` lookup result as a list where necessary #}
|
||||
{#- since we need to also handle grains that are lists #}
|
||||
{%- if fs_dirs is string %}
|
||||
{%- set fs_dirs = [fs_dirs] %}
|
||||
{%- endif %}
|
||||
{%- for fs_dir in fs_dirs %}
|
||||
{%- set url = [
|
||||
'- salt:/',
|
||||
path_prefix_inc_ext.strip('/'),
|
||||
files_dir.strip('/'),
|
||||
fs_dir.strip('/'),
|
||||
src_file.strip('/'),
|
||||
] | select | join('/') %}
|
||||
{{ url | indent(indent_width, true) }}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
|
|
Loading…
Add table
Reference in a new issue