Skip to content

Commit

Permalink
refactor(tplroot): use tplroot instead of topdir to match tpldata
Browse files Browse the repository at this point in the history
* Upstream feature request PR:
  - saltstack/salt#51814
  • Loading branch information
myii committed Feb 26, 2019
1 parent c10c64e commit d5d140c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
10 changes: 5 additions & 5 deletions template/config/clean.sls
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- set sls_service_clean = topdir ~ '.service.clean' %}
{%- from topdir ~ "/map.jinja" import template with context %}
{%- from topdir ~ "/macros.jinja" import files_switch with context %}
{#- Get the `tplroot` from `tpldir` #}
{%- 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 %}
include:
- {{ sls_service_clean }}
Expand Down
12 changes: 6 additions & 6 deletions template/config/file.sls
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- set sls_pkg_install = topdir ~ '.pkg.install' %}
{%- from topdir ~ "/map.jinja" import template with context %}
{%- from topdir ~ "/macros.jinja" import files_switch with context %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_pkg_install = tplroot ~ '.pkg.install' %}
{%- from tplroot ~ "/map.jinja" import template with context %}
{%- from tplroot ~ "/macros.jinja" import files_switch with context %}
include:
- {{ sls_pkg_install }}
Expand All @@ -15,7 +15,7 @@ template-config:
- name: {{ template.config }}
- source: {{ files_switch(
salt['config.get'](
topdir ~ ':tofs:files:template-config',
tplroot ~ ':tofs:files:template-config',
['example.tmpl', 'example.tmpl.jinja']
)
) }}
Expand Down
14 changes: 7 additions & 7 deletions template/macros.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
- salt://xxx/files/default/etc/yyy/zzz.conf.jinja
- template: jinja
#}
{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- set path_prefix = salt['config.get'](topdir ~ ':tofs:path_prefix', topdir) %}
{%- set files_dir = salt['config.get'](topdir ~ ':tofs:dirs:files', 'files') %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set path_prefix = salt['config.get'](tplroot ~ ':tofs:path_prefix', tplroot) %}
{%- set files_dir = salt['config.get'](tplroot ~ ':tofs:dirs:files', 'files') %}
{%- set files_switch_list = salt['config.get'](
topdir ~ ':tofs:files_switch',
tplroot ~ ':tofs:files_switch',
default_files_switch
) %}
{#- Only add to [''] when supporting older TOFS implementations #}
Expand All @@ -56,7 +56,7 @@
{#- For older TOFS implementation, use `files_switch` from the pillar #}
{#- Use the default, new method otherwise #}
{%- set fsl = salt['pillar.get'](
topdir ~ path_prefix_ext|replace('/', ':') ~ ':files_switch',
tplroot ~ path_prefix_ext|replace('/', ':') ~ ':files_switch',
files_switch_list
) %}
{#- Append an empty value to evaluate as `default` in the loop below #}
Expand All @@ -68,7 +68,7 @@
{%- if fs %}
{%- set fs_dir = salt['config.get'](fs, fs) %}
{%- else %}
{%- set fs_dir = salt['config.get'](topdir ~ ':tofs:dirs:default', 'default') %}
{%- set fs_dir = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
{%- endif %}
{%- set url = '- salt://' ~ '/'.join([
path_prefix_inc_ext,
Expand Down
12 changes: 6 additions & 6 deletions template/map.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{#- Start imports as #}
{%- import_yaml topdir ~ "/defaults.yaml" as default_settings %}
{%- import_yaml topdir ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml topdir ~ "/osmap.yaml" as osmap %}
{%- import_yaml topdir ~ "/osfingermap.yaml" as osfingermap %}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}

{% set defaults = salt['grains.filter_by'](default_settings,
default='template',
Expand Down
8 changes: 4 additions & 4 deletions template/pkg/clean.sls
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- set sls_config_clean = topdir ~ '.config.clean' %}
{%- from topdir ~ "/map.jinja" import template with context %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_clean = tplroot ~ '.config.clean' %}
{%- from tplroot ~ "/map.jinja" import template with context %}
include:
- {{ sls_config_clean }}
Expand Down
6 changes: 3 additions & 3 deletions template/pkg/install.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- from topdir ~ "/map.jinja" import template with context %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import template with context %}
template-pkg:
pkg.installed:
Expand Down
6 changes: 3 additions & 3 deletions template/service/clean.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- from topdir ~ "/map.jinja" import template with context %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import template with context %}
template-service-dead:
service.dead:
Expand Down
8 changes: 4 additions & 4 deletions template/service/running.sls
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{%- set sls_config_file = topdir ~ '.config.file' %}
{%- from topdir ~ "/map.jinja" import template with context %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import template with context %}
include:
- {{ sls_config_file }}
Expand Down

0 comments on commit d5d140c

Please sign in to comment.