-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(tofs): avoid using “salt['config.get']” for formula writers #77
refactor(tofs): avoid using “salt['config.get']” for formula writers #77
Conversation
041d261
to
8003492
Compare
Hello. I think I can rewrite the commit message since it actually breaks things. Maybe there is a better way of doing it, it's open to suggestion. Regards |
@baby-gnu Just had a brief glance -- this looks like a very good idea. What break things -- just the commit message or something else? |
@baby-gnu I've had a chance to look at this and test it out and I definitely agree that this is the right way to go forwards -- thanks for the contribution! However, I'd just like a couple of things cleaned up, as I've mentioned in my comments above. I also want to ask @aboe76 to have a look, so that we can be confident that we're heading in the right direction. I've tested before and after with the following in my pillar (includes some extra test states for tofs:
files_switch:
- any/path/can/be/used/here
- id
- osfinger
- os
- os_family
path_prefix: template_alt
dirs:
files: files_alt
default: default_alt
source_files:
template-config-file-file-managed:
- 'example_alt_source.tmpl'
- 'example_alt.tmpl.jinja'
formula.autofs.config.master:
- 'auto_alt.master'
formula.autofs.config.home:
- 'auto_alt.homeLdap'
formula.autofs.config.away:
- 'auto_alt.awayLdap' I've got the same results before and after: - source:
- salt://template_alt/files_alt/any/path/can/be/used/here/example_alt_source.tmpl
- salt://template_alt/files_alt/any/path/can/be/used/here/example_alt.tmpl.jinja
- salt://template_alt/files_alt/ABC/example_alt_source.tmpl
- salt://template_alt/files_alt/ABC/example_alt.tmpl.jinja
- salt://template_alt/files_alt/Ubuntu-16.04/example_alt_source.tmpl
- salt://template_alt/files_alt/Ubuntu-16.04/example_alt.tmpl.jinja
- salt://template_alt/files_alt/Ubuntu/example_alt_source.tmpl
- salt://template_alt/files_alt/Ubuntu/example_alt.tmpl.jinja
- salt://template_alt/files_alt/Debian/example_alt_source.tmpl
- salt://template_alt/files_alt/Debian/example_alt.tmpl.jinja
- salt://template_alt/files_alt/default_alt/example_alt_source.tmpl
- salt://template_alt/files_alt/default_alt/example_alt.tmpl.jinja
- source:
- salt://template_alt/files_alt/any/path/can/be/used/here/auto_alt.master
- salt://template_alt/files_alt/ABC/auto_alt.master
- salt://template_alt/files_alt/Ubuntu-16.04/auto_alt.master
- salt://template_alt/files_alt/Ubuntu/auto_alt.master
- salt://template_alt/files_alt/Debian/auto_alt.master
- salt://template_alt/files_alt/default_alt/auto_alt.master
- source:
- salt://template_alt/files_alt/any/path/can/be/used/here/auto_alt.homeLdap
- salt://template_alt/files_alt/ABC/auto_alt.homeLdap
- salt://template_alt/files_alt/Ubuntu-16.04/auto_alt.homeLdap
- salt://template_alt/files_alt/Ubuntu/auto_alt.homeLdap
- salt://template_alt/files_alt/Debian/auto_alt.homeLdap
- salt://template_alt/files_alt/default_alt/auto_alt.homeLdap
- source:
- salt://template_alt/files_alt/any/path/can/be/used/here/auto_alt.awayLdap
- salt://template_alt/files_alt/ABC/auto_alt.awayLdap
- salt://template_alt/files_alt/Ubuntu-16.04/auto_alt.awayLdap
- salt://template_alt/files_alt/Ubuntu/auto_alt.awayLdap
- salt://template_alt/files_alt/Debian/auto_alt.awayLdap
- salt://template_alt/files_alt/default_alt/auto_alt.awayLdap So I'm happy with this implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two changes:
{#-
- Avoid using
files
, which can be mixed up with thefiles
intofs:dir:files
.- I've made the suggestions inline to use
src_file
andsrc_files
for these variables.
- I've made the suggestions inline to use
Another change to be discussed:
- This comment about whether it is worth keeping
namespace=
andsource_files=
or not.
You could also fix the typo in the commit message:
forumla
=>formula
.
template/config/file.sls
Outdated
) | ||
) }} | ||
- source: {{ files_switch(namespace='template-config-file-file-managed', | ||
source_files=['example.tmpl', 'example.tmpl.jinja'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using namespace=
and source_files=
seems to make sense at this stage. However, I think it just makes this longer than in needs to be. Not pushing this issue, just opening it for discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe lookup=
is much more meanful than namespace=
.
The To make it compatible with users calling directly
This way it can be used as
or
It could even be missused (doing the lookup two times) with:
So, feature or refactor? ;-) |
d8292e2
to
62d1d24
Compare
I rebased my work, integrating the different comments made. The I changed the new variable name, position and optionality. People using the old format are not forced to change, they can still call
or they can change and use the new optional
There is no error if the formula writer mistakely added the
Regards. |
Restarted the failing tests and all OK from that end. |
We can hide the call to “salt['config.get']” in the macro by only asking for a “lookup key” where to lookup the list of “source_files”. * docs/TOFS_pattern.rst (Example): document the use of the new optional “lookup” parameter. * template/macros.jinja: add a new optional “lookup” parameter. Lookup “files override” under the “<tplroot>:tofs:sources_files:<lookup key>” and fallback to “source_files” parameter. * template/config/file.sls (template-config-file-file-managed): use the new “lookup” parameter.
62d1d24
to
60d43e7
Compare
@baby-gnu I'm really happy with this now -- an excellent refactor. Thanks for your work and your patience. Would you be willing to submit a follow-up PR to update @aboe76 I'm happy with this to be merged, if you are OK with the changes as well. |
I should have missed something @myii because I updated the example in |
@baby-gnu You're right, it has been updated! I didn't look at the whole file, so I thought there may be more changes needed. |
UPDATE: Please leave this table for the time being, until the @baby-gnu As discussed on IRC/Matrix, list of formulas to be updated:
@babilen5 Sorry for the false ping, somehow got you instead of @baby-gnu! |
So |
Hello.
I like the idea, but for systemd-formula it looks like there are some specific things to lookup files under the sub-directories for each component. I did not took enough time to look at it but I think a Regards. |
@alxwr I really like the idea of a To all, thanks for your work, reviews and ideas. |
🎉 This PR is included in version 1.2.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
We can hide the call to “salt['config.get']” in the macro by only
asking for a namespace where to lookup the “source_files”.
docs/TOFS_pattern.rst (Example): document the use of the new
“namespace” parameter.
template/macros.jinja: add a new “namespace” parameter.
Lookup files override under
“:tofs:sources_files:” and fallback to
“source_files” parameter.
template/config/file.sls (template-config-file-file-managed): use
the new “namespace” parameter