Skip to content

Conversation

@myii
Copy link
Contributor

@myii myii commented Feb 26, 2019

Note: Happy to rebase the commits to remove the commit body text if a hindrance of any kind.


What does this PR do?

Working on making SaltStack Formulas portable, find the need for a
common point of reference. Comparing the import of map.jinja with and
without context:

tpldata without context with context
tplfile template/map.jinja template/pkg/install.sls
tpldir template template/pkg
tpldot template template.pkg
tplroot template template

With tplroot, it is possible to use a single point of reference for
all paths, avoiding the various incantations currently used, such as:

  • from tpldir ~ "/map.jinja" import ...
  • from salt.file.dirname(tpldir) ~ "/map.jinja" import ...
  • from salt['file.dirname'](tpldir) ~ "/map.jinja" import ...

In all of the above circumstances, this simply becomes:

  • from tplroot ~ "/map.jinja" import ...

Additional benefits are gained when referencing by colon : for pillars
or by period . for include statements or for any requisites.

What issues does this PR fix or reference?

Related issues: #10838, #41195.
Related PR: saltstack-formulas/template-formula#48.

Tests written?

No.

Commits signed with GPG?

No.

myii added 2 commits February 26, 2019 00:13
Working on making SaltStack Formulas portable, find the need for a
common point of reference.  Comparing the import of `map.jinja` with and
without context:

| `tpldata` | without context    | with context             |
|-----------|--------------------|--------------------------|
| `tplfile` | template/map.jinja | template/pkg/install.sls |
| `tpldir`  | template           | template/pkg             |
| `tpldot`  | template           | template.pkg             |
| `tplroot` | template           | template                 |

With `tplroot`, it is possible to use a single point of reference for
all paths, avoiding the various incantations currently used, such as:

* `from tpldir ~ "/map.jinja" import ...`
* `from salt.file.dirname(tpldir) ~ "/map.jinja" import ...`
* `from salt['file.dirname'](tpldir) ~ "/map.jinja" import ...`

In all of the above circumstances, this simply becomes:

* `from tplroot ~ "/map.jinja" import ...`

Additional benefits are gained when referencing by colon `:` for pillars
or by period `.` for `include` statements or for any requisites.

Related issues: saltstack#10838, saltstack#41195.
@cmcmarrow cmcmarrow self-requested a review June 14, 2019 20:17
@Akm0d Akm0d merged commit c24dfef into saltstack:develop Jun 20, 2019
myii added a commit to myii/template-formula that referenced this pull request Jun 25, 2019
myii added a commit to myii/template-formula that referenced this pull request Jun 25, 2019
@myii myii deleted the feature/tplroot branch January 21, 2020 18:14
@sagetherage sagetherage added has master-port port to master has been created and removed master-port labels May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has master-port port to master has been created

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants