-
Notifications
You must be signed in to change notification settings - Fork 86
test(pillar): use static test/salt/pillar/top.sls #238
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
Merged
myii
merged 2 commits into
saltstack-formulas:master
from
baby-gnu:test/pillar-top-from-file
Nov 16, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # vim: ft=yaml | ||
| --- | ||
| TEMPLATE: | ||
| lookup: | ||
| master: template-master | ||
| # Just for testing purposes | ||
| winner: lookup | ||
| added_in_lookup: lookup_value | ||
|
|
||
| # Using bash package and udev service as an example. This allows us to | ||
| # test the template formula itself. You should set these parameters to | ||
| # examples that make sense in the contexto of the formula you're writing. | ||
| pkg: | ||
| name: bash | ||
| service: | ||
| name: systemd-journald | ||
| config: /etc/template-formula.conf | ||
|
|
||
| tofs: | ||
| # The files_switch key serves as a selector for alternative | ||
| # directories under the formula files directory. See TOFS pattern | ||
| # doc for more info. | ||
| # Note: Any value not evaluated by `config.get` will be used literally. | ||
| # This can be used to set custom paths, as many levels deep as required. | ||
| files_switch: | ||
| - any/path/can/be/used/here | ||
| - id | ||
| - roles | ||
| - osfinger | ||
| - os | ||
| - os_family | ||
| # All aspects of path/file resolution are customisable using the options below. | ||
| # This is unnecessary in most cases; there are sensible defaults. | ||
| # Default path: salt://< path_prefix >/< dirs.files >/< dirs.default > | ||
| # I.e.: salt://TEMPLATE/files/default | ||
| # path_prefix: template_alt | ||
| # dirs: | ||
| # files: files_alt | ||
| # default: default_alt | ||
| # The entries under `source_files` are prepended to the default source files | ||
| # given for the state | ||
| # source_files: | ||
| # TEMPLATE-config-file-file-managed: | ||
| # - 'example_alt.tmpl' | ||
| # - 'example_alt.tmpl.jinja' | ||
|
|
||
| # For testing purposes | ||
| source_files: | ||
| TEMPLATE-config-file-file-managed: | ||
| - 'example.tmpl.jinja' | ||
| TEMPLATE-subcomponent-config-file-file-managed: | ||
| - 'subcomponent-example.tmpl.jinja' | ||
|
|
||
| # Just for testing purposes | ||
| winner: pillar | ||
| added_in_pillar: pillar_value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # vim: ft=yaml | ||
| --- | ||
| base: | ||
| '*': | ||
| - default | ||
| 'G@os_family:Gentoo': | ||
| - gentoo | ||
| 'os:*': | ||
| - define_roles | ||
| ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
We probably can avoid a dedicated
test/salt/pillar/top.slsand just adapt the same method used in other formulas understate_top.Some examples:
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.
Yes, It could be done from
kitchen.ymldirectly but the main point of having a dedicatedtop.slsis to be able to run it outside kitchen.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.
@baby-gnu I haven't come across this idea before -- could you give me an example of this being run outside of Kitchen? Does this also apply to the using the
state_top'stop.slsas a separate file as well?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.
The idea came from user colttt on SaltStack matrix room to better validate formula since
salt-lintdoes not cover all possible errors.colttt uses the following command to compile the states:
But it can't be done easily when the formula requires pillars.
Then, my idea is to provide all the necessary to try out a formula in two steps:
There is no point in having
state_top'stop.slsin a dedicated file too since there is nosalt-calloption to select that file and I think we should avoid having one in the formula directory referenced by the--file-rootoption above.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.
@baby-gnu The example you've shared doesn't appear to work, because the
TEMPLATEpillar (i.e.pillar.example) is not in that directory:If I comment out the
TEMPLATEline in the newly providedtop.sls, then the state runs -- but obviously missing everything frompillar.example(theTEMPLATEpillar).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.
Yes, that's an issue.
To be completely functional, the
test/salt/pillar/should contains all the required files, in which case:pillars_from_filesis no more usedpillar.exampleis just an example and not a seed for tests.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.
I push a second commit to move testing values from
pillar.exampletotest/salt/pillar/TEMPLATE.slsand removepillars_from_filesfromkitchen.yml.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.
@baby-gnu If we're going to attempt to use these ideas across existing formulas then that's not going to be fun to refactor. There are more formulas using
pillar.examplein the CI than any other file. Due to that, it's the default value used from thessf-formulaas well.ssf-formula.We can discuss the relative merits of this idea in the upcoming meeting. I'm still not quite sure what the use cases are so it would great if you could demonstrate it.