From 2838bc904125918671ad3e73fe1f50885291bf79 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 14:09:31 +0000 Subject: [PATCH] refactor(tpldir): use `topdir` globally in place of `tpldir` * `topdir` evaluates to the formula's root directory * Maintains formula's portability by providing consistent navigation --- template/pkg/clean.sls | 4 +++- template/pkg/config.sls | 5 +++-- template/pkg/install.sls | 4 +++- template/pkg/service.sls | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/template/pkg/clean.sls b/template/pkg/clean.sls index 1f7b8f12..daf3dfb9 100644 --- a/template/pkg/clean.sls +++ b/template/pkg/clean.sls @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} template-service-dead: service.dead: diff --git a/template/pkg/config.sls b/template/pkg/config.sls index ddc67484..b921ba18 100644 --- a/template/pkg/config.sls +++ b/template/pkg/config.sls @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=sls +{#- Get the `topdir` from `tpldir` #} {%- set topdir = tpldir.split('/')[0] %} -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} -{%- from salt['file.dirname'](tpldir) ~ "/macros.jinja" import files_switch with context %} +{%- from topdir ~ "/map.jinja" import template with context %} +{%- from topdir ~ "/macros.jinja" import files_switch with context %} include: - .install diff --git a/template/pkg/install.sls b/template/pkg/install.sls index a2e4eb72..d71cbec9 100644 --- a/template/pkg/install.sls +++ b/template/pkg/install.sls @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} template-pkg: pkg.installed: diff --git a/template/pkg/service.sls b/template/pkg/service.sls index 2449736a..b2c4dbc5 100644 --- a/template/pkg/service.sls +++ b/template/pkg/service.sls @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} include: - .config