Skip to content

Commit

Permalink
refactor(tofs): move “files_switch” macro to “libtofs.jinja”
Browse files Browse the repository at this point in the history
BREAKING CHANGE: every formula writer will need to change the import
to use this new version.

* template/libtofs.jinja: provides the “files_switch” macro.

* docs/TOFS_pattern.rst: update documentation to use the new path.

* template/config/clean.sls: change import from “macros.jinja” to “libtofs.jinja”.

* template/config/file.sls: ditoo.
  • Loading branch information
baby-gnu committed Mar 21, 2019
1 parent 6d2140f commit da7e692
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/TOFS_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ We can simplify the ``conf.sls`` with the new ``files_switch`` macro to use in t
{%- set tplroot = tpldir.split('/')[0] %}
{%- from 'ntp/map.jinja' import ntp with context %}
{%- from 'ntp/macros.jinja' import files_switch %}
{%- from 'ntp/libtofs.jinja' import files_switch %}
Configure NTP:
file.managed:
Expand All @@ -327,10 +327,10 @@ We can simplify the ``conf.sls`` with the new ``files_switch`` macro to use in t
* This uses ``config.get``, searching for ``ntp:tofs:source_files:Configure NTP`` to determine the list of template files to use.
* If this does not yield any results, the default of ``['/etc/ntp.conf.jinja']`` will be used.

In ``macros.jinja``, we define this new macro ``files_switch``.
In ``libtofs.jinja``, we define this new macro ``files_switch``.

.. literalinclude:: ../template/macros.jinja
:caption: /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/macros.jinja
.. literalinclude:: ../template/libtofs.jinja
:caption: /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/libtofs.jinja
:language: jinja

How to customise the ``source`` further
Expand Down
2 changes: 1 addition & 1 deletion template/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- from tplroot ~ "/map.jinja" import template with context %}
{%- from tplroot ~ "/macros.jinja" import files_switch with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
include:
- {{ sls_service_clean }}
Expand Down
2 changes: 1 addition & 1 deletion template/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/map.jinja" import template with context %}
{%- from tplroot ~ "/macros.jinja" import files_switch with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
include:
- {{ sls_package_install }}
Expand Down
File renamed without changes.

0 comments on commit da7e692

Please sign in to comment.