Skip to content

Commit 52d03d8

Browse files
committed
refactor(tpldir): use tpldir or derivatives to make formula portable
* Close saltstack-formulas#22.
1 parent c246939 commit 52d03d8

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

template/config.sls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=sls
33

4-
{%- from "template/map.jinja" import template with context %}
5-
{%- from "template/macros.jinja" import files_switch with context %}
4+
{%- from tpldir ~ "/map.jinja" import template with context %}
5+
{%- from tpldir ~ "/macros.jinja" import files_switch with context %}
66
77
include:
88
- template.install

template/install.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=sls
33

4-
{% from "template/map.jinja" import template with context %}
4+
{%- from tpldir ~ "/map.jinja" import template with context %}
55
66
template-pkg:
77
pkg.installed:

template/map.jinja

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
33

4-
{## Start imports as ##}
5-
{% import_yaml 'template/defaults.yaml' as default_settings %}
6-
{% import_yaml 'template/osfamilymap.yaml' as osfamilymap %}
7-
{% import_yaml 'template/osmap.yaml' as osmap %}
8-
{% import_yaml 'template/osfingermap.yaml' as osfingermap %}
4+
{#- Get the `topdir` from `tpldir` #}
5+
{%- set topdir = tpldir.split('/')[0] %}
6+
{#- Start imports as #}
7+
{%- import_yaml topdir ~ "/defaults.yaml" as default_settings %}
8+
{%- import_yaml topdir ~ "/osfamilymap.yaml" as osfamilymap %}
9+
{%- import_yaml topdir ~ "/osmap.yaml" as osmap %}
10+
{%- import_yaml topdir ~ "/osfingermap.yaml" as osfingermap %}
911

1012
{% set defaults = salt['grains.filter_by'](default_settings,
1113
default='template',
@@ -18,5 +20,5 @@
1820
)
1921
) %}
2022

21-
{## Merge the template pillar ##}
23+
{#- Merge the template pillar #}
2224
{% set template = salt['pillar.get']('template', default=defaults, merge=True) %}

template/service.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=sls
33

4-
{% from "template/map.jinja" import template with context %}
4+
{%- from tpldir ~ "/map.jinja" import template with context %}
55
66
include:
77
- template.config

0 commit comments

Comments
 (0)