Add utility functions to slsutil module#49396
Merged
Merged
Conversation
cachedout
suggested changes
Aug 29, 2018
| block.append(blockend) | ||
|
|
||
| # Convert list to multiline string | ||
| result = '\n'.join(block) |
Contributor
There was a problem hiding this comment.
For better multi-platform support we should probably use os.linesep here instead
Contributor
Author
There was a problem hiding this comment.
That suggestion sounded right to me, but the documentation is making me think not:
Do not use os.linesep as a line terminator when writing files opened in text mode (the default); use a single '\n' instead, on all platforms.
It seems that Python converts \n to os.linesep when it writes out the file.
Contributor
There was a problem hiding this comment.
The files aren't ultimately opened in text mode, though. That's the thing. :)
Contributor
|
Port to master #56761 |
Contributor
Author
|
@s0undt3ch Please consider bringing #53499 along with this one. It includes a few fixes to the original PR. |
Contributor
|
@amendlik Thank You! Will do. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Add two utility functions to the
slsutilexecution module. These functions are for convenience when creating template files.Banner
slsutil.bannercreates a standard warning banner like this:The banner is fully customizable in its content and appearance.
Boolstr
slsutil.boolstris for converting boolean values stored in Pillar to an appropriate string representation within templated files. This can obviously be done in Jinja, but it requires an entire if/else block and managing whitespace becomes difficult.See embedded documentation for more details.
What issues does this PR fix or reference?
None
Tests written?
Yes
Commits signed with GPG?
Yes
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.