Skip to content

Commit 0979d35

Browse files
committed
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.
1 parent 13f1728 commit 0979d35

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

template/libtofs.jinja

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,25 @@
8383
{%- for fs in fsl %}
8484
{%- for src_file in src_files %}
8585
{%- if fs %}
86-
{%- set fs_dir = salt['config.get'](fs, fs) %}
86+
{%- set fs_dirs = salt['config.get'](fs, fs) %}
8787
{%- else %}
88-
{%- set fs_dir = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
88+
{%- set fs_dirs = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
8989
{%- endif %}
90-
{%- set url = [
91-
'- salt:/',
92-
path_prefix_inc_ext.strip('/'),
93-
files_dir.strip('/'),
94-
fs_dir.strip('/'),
95-
src_file.strip('/'),
96-
] | select | join('/') %}
90+
{#- Force the `config.get` lookup result as a list where necessary #}
91+
{#- since we need to also handle grains that are lists #}
92+
{%- if fs_dirs is string %}
93+
{%- set fs_dirs = [fs_dirs] %}
94+
{%- endif %}
95+
{%- for fs_dir in fs_dirs %}
96+
{%- set url = [
97+
'- salt:/',
98+
path_prefix_inc_ext.strip('/'),
99+
files_dir.strip('/'),
100+
fs_dir.strip('/'),
101+
src_file.strip('/'),
102+
] | select | join('/') %}
97103
{{ url | indent(indent_width, true) }}
104+
{%- endfor %}
98105
{%- endfor %}
99106
{%- endfor %}
100107
{%- endfor %}

0 commit comments

Comments
 (0)