Skip to content

Commit

Permalink
feat(map.jinja): map.jinja can't be used with Jinja2 dot notation
Browse files Browse the repository at this point in the history
* TEMPLATE/map.jinja: rename `map.jinja:sources` to `map_jinja:sources`.

* TEMPLATE/parameters/defaults.yaml: rename `map.jinja` key to `map_jinja`.

* test/integration/default/controls/config_spec.rb: fix test for the rename.
  • Loading branch information
baby-gnu committed Feb 24, 2020
1 parent f59c484 commit de39591
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions TEMPLATE/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
{%- import_yaml _defaults_filename as default_settings %}

{# List of sources to lookup for parameters #}
{%- do salt.log.debug('map.jinja: lookup map.jinja configuration sources') %}
{%- do salt.log.debug("map.jinja: lookup 'map_jinja' configuration sources") %}
{# Fallback to previously used grains plus minion `id` #}
{%- set map_sources = ['osarch', 'os_family', 'os', 'osfinger', 'id'] %}
{# Configure map.jinja from defaults.yaml #}
{%- set map_sources = default_settings | traverse('map.jinja:sources', map_sources) %}
{%- set map_sources = default_settings | traverse('map_jinja:sources', map_sources) %}

{# Lookup global sources #}
{%- set map_sources = salt['config.get']('map.jinja:sources', map_sources) %}
{%- set map_sources = salt['config.get']('map_jinja:sources', map_sources) %}
{# Lookup per formula sources #}
{%- set map_sources = salt['config.get'](tplroot ~ ':map.jinja:sources', map_sources) %}
{%- set map_sources = salt['config.get'](tplroot ~ ':map_jinja:sources', map_sources) %}

{%- do salt.log.debug('map.jinja: load parameters with sources from ' ~ map_sources) %}

Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/parameters/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ winner: defaults
# `smart` strategy of `salt.slsutil.merge`.
# Note: Any value not evaluated by `config.get` will be used literally.
# This can be used to set custom paths, as many levels deep as required.
map.jinja:
map_jinja:
sources:
- osarch
- os_family
Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
its('content') { should include 'winner of the merge: pillar' }
its('content') do
should include(
'"map.jinja": {"sources": ["osarch", "os_family", "os", "osfinger", "roles", ' \
'"map_jinja": {"sources": ["osarch", "os_family", "os", "osfinger", "roles", ' \
'"id", "any/path/can/be/used/here.yaml"]}'
)
end
Expand Down

0 comments on commit de39591

Please sign in to comment.