-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add customizable warning not to directly edit settings.py #210
base: master
Are you sure you want to change the base?
Conversation
Following up from some IRC conversation, my take on things was: I like if we could across our ecosystem have a consistent header for our modules. You can see for example, https://github.com/theforeman/puppet-foreman/blob/master/templates/_header.erb, is used across a few different modules already as a format. This PR raises a desire to sometimes customize the degree and intent of the message for the file. Thus, I would propose a hybrid of the two. A standard starting header followed by any custom message, e.g.
And I think it's fair to challenge if the current headers message, what would serve as our base template across modules, needs some updating or modification to be more relevant to more use cases. Could it be configurable by the installer? Possibly. One tricky bit could be that comments may be different amongst different files (that is |
483da42
to
90bd343
Compare
Updated this with a custom function, This takes an Array of Strings ( It also introduces a new class This way downstream projects can use Hiera to add custom content to headers, while pure Puppet users will see a sensible default for Puppet. In the future, most of this logic should be removed from this module and placed in a common module that can be used throughout the installer ecosystem. TODO: Add tests |
90bd343
to
209c397
Compare
In the current implementation, see the complete header as well as the beginning of the rest of the settings.py content below: ################################################################################
# !!! WARNING: DO NOT EDIT THIS FILE !!! #
################################################################################
# File managed by Puppet. #
# Module: pulpcore #
################################################################################
# Not only are your edits likely to be overwritten, there is also a strong #
# possibility of breaking your system if you change configuration here without #
# making required changes elsewhere. Refer to the documentation you used to #
# install Pulpcore to determine the safe and persistent way to modify the #
# configuration. #
################################################################################
CONTENT_HOST = "centos7-64-1"
CONTENT_ORIGIN = "https://centos7-64-1" In general with this method, the number of text blocks in the header is optional. Any Array of Strings can be passed, and each string will be line wrapped and enclosed in the comment_glyph. As currently implemented in this module, the # of blocks and content of the first text block is static, while the 2nd and 3rd are configurable by setting With appropriate hiera in foreman-installer, this might look instead like, e.g.: ################################################################################
# !!! WARNING: DO NOT EDIT THIS FILE !!! #
################################################################################
# File managed by foreman-installer. #
# Module: pulpcore #
################################################################################
# Configure Pulpcore using foreman-installer. See foreman-installer --help #
################################################################################ Or any other custom string providing appropriate guidance to the user. |
209c397
to
b75c086
Compare
$settings_header_content = pulpcore::generate_header_content( | ||
[ | ||
$warning_header, | ||
$installer_header, | ||
$explanation, | ||
], | ||
80, | ||
'#', | ||
) |
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.
$settings_header_content = pulpcore::generate_header_content( | |
[ | |
$warning_header, | |
$installer_header, | |
$explanation, | |
], | |
80, | |
'#', | |
) | |
$settings_header_content = pulpcore::generate_header_content( | |
{ | |
raw_content => [ | |
$warning_header, | |
$installer_header, | |
$explanation, | |
], | |
line_width => 80, | |
comment_glyph => '#', | |
} | |
) |
I'm not actually sure if Puppet function calls support named arguments in this way, but if so I'd like to give it a try for better readability
@@ -0,0 +1,20 @@ | |||
Puppet::Functions.create_function(:'pulpcore::generate_header_content') do |
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 suppose a name like wrap_and_comment_header_content
would be more descriptive here. Open to suggestions
Also trying to determine what would be the correct place to open a PR with this function upstream. Perhaps it makes the most sense in the Concat module?
e4e1db8
to
7feb95e
Compare
I'll spend more time digging into it. My initial two thoughts are:
|
voxpupuli/puppet-extlib#171 does take that idea. I think that or stdlib would be good places. |
This has been open for a year now, I am therefore tempted to close it as it can be re-visited in the future if desired. @wbclark thoughts? |
No description provided.