Skip to content

Commit

Permalink
Merge pull request #156 from myii/fix/opt-in-for-libtofs-subpaths
Browse files Browse the repository at this point in the history
fix(libtofs): avoid using subpath by default
  • Loading branch information
aboe76 authored Aug 9, 2019
2 parents f63e73c + ad2a965 commit fc3a130
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/TOFS_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ For example, the following ``formula.component.config`` SLS:
- mode: 644
- template: jinja
- source: {{ files_switch(['formula.conf'],
lookup='formula'
lookup='formula',
use_subpath=True
)
}}
Expand Down
10 changes: 4 additions & 6 deletions template/libtofs.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lookup=None,
default_files_switch=['id', 'os_family'],
indent_width=6,
v1_path_prefix='') %}
use_subpath=False) %}
{#-
Returns a valid value for the "source" parameter of a "file.managed"
state function. This makes easier the usage of the Template Override and
Expand All @@ -17,8 +17,8 @@
use as selector switch of the directories under
"<path_prefix>/files"
* indent_witdh: indentation of the result value to conform to YAML
* v1_path_prefix: (deprecated) only used for injecting a path prefix into
the source, to support older TOFS configs
* use_subpath: defaults to `False` but if set, lookup the source file
recursively from the current state directory up to `tplroot`
Example (based on a `tplroot` of `xxx`):
Expand Down Expand Up @@ -64,9 +64,7 @@
{%- set src_files = src_files + source_files %}
{#- Only add to [''] when supporting older TOFS implementations #}
{%- set path_prefix_exts = [''] %}
{%- if v1_path_prefix != '' %}
{%- do path_prefix_exts.append(v1_path_prefix) %}
{%- elif tplroot != tpldir %}
{%- if use_subpath and tplroot != tpldir %}
{#- Walk directory tree to find {{ files_dir }} #}
{%- set subpath_parts = tpldir.lstrip(tplroot).lstrip('/').split('/') %}
{%- for path in subpath_parts %}
Expand Down
3 changes: 2 additions & 1 deletion template/subcomponent/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ template-subcomponent-config-file-file-managed:
file.managed:
- name: {{ template.subcomponent.config }}
- source: {{ files_switch(['subcomponent-example.tmpl'],
lookup='template-subcomponent-config-file-file-managed'
lookup='template-subcomponent-config-file-file-managed',
use_subpath=True
)
}}
- mode: 644
Expand Down

0 comments on commit fc3a130

Please sign in to comment.