-
Notifications
You must be signed in to change notification settings - Fork 43
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 new configuration option for puppet classes #338
base: master
Are you sure you want to change the base?
Changes from 3 commits
44a2f4c
f0de2e7
0216c9f
ee2c6ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,11 +388,15 @@ def set_options | |
end | ||
|
||
modules.each do |mod| | ||
app_option d("--[no-]enable-#{mod.name}"), :flag, "Enable '#{mod.name}' puppet module", | ||
:default => mod.enabled? | ||
if mod.can_disable? | ||
app_option d("--[no-]enable-#{mod.name}"), :flag, "Enable '#{mod.name}' puppet module (current: #{mod.enabled?})", :default => mod.enabled? | ||
elsif !mod.enabled? | ||
app_option d("--enable-#{mod.name}"), :flag, "Enable '#{mod.name}' puppet module (current: #{mod.enabled?})" | ||
end | ||
Comment on lines
+393
to
+395
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess https://github.com/theforeman/kafo/pull/338/files#r701787011 should rather have been here, but 🤷♀️ |
||
end | ||
|
||
params.sort.each do |param| | ||
next if param.module.excluded_param?(dashize(param.name)) | ||
doc = param.doc.nil? ? 'UNDOCUMENTED' : param.doc.join("\n") | ||
app_option parametrize(param), '', doc + " (current: #{param.value_to_s})", | ||
:multivalued => param.multivalued? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,5 +340,54 @@ module Kafo | |
_(stdout).must_include "Hello Kafo\nGoodbye" | ||
end | ||
end | ||
|
||
describe 'with classes' do | ||
it 'includes enable flag by default' do | ||
code, out, err = run_command '../bin/kafo-configure --help' | ||
_(code).must_equal 0, err | ||
_(out).must_include "--[no-]enable-testing" | ||
end | ||
|
||
it 'does not show disable flag if class cannot be disabled' do | ||
config = YAML.load_file(KAFO_CONFIG) | ||
config[:classes] = {:testing => {:can_disable => false}} | ||
File.open(KAFO_CONFIG, 'w') do |file| | ||
file.write(config.to_yaml) | ||
end | ||
|
||
code, out, err = run_command '../bin/kafo-configure --help' | ||
_(code).must_equal 0, err | ||
_(out).wont_include "--[no-]enable-testing" | ||
end | ||
|
||
it 'shows enable flag if class is disabled' do | ||
config = YAML.load_file(KAFO_CONFIG) | ||
config[:classes] = {:testing => {:can_disable => false}} | ||
File.open(KAFO_CONFIG, 'w') do |file| | ||
file.write(config.to_yaml) | ||
end | ||
|
||
answers = {'testing' => false} | ||
File.open(KAFO_ANSWERS, 'w') do |file| | ||
file.write(answers.to_yaml) | ||
end | ||
|
||
code, out, err = run_command '../bin/kafo-configure --help' | ||
_(code).must_equal 0, err | ||
_(out).must_include "--enable-testing" | ||
end | ||
Comment on lines
+363
to
+378
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does that mean that when I've run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a fair point. My thought was, if the option does nothing, why include it. There are a couple ideas:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Demoting it to While we can (and should) make the Ansible life easier by making it understand the installer, we also have users out there who have a 50+ page PDF "how to install/upgrade $project" and they will re-use the same installer parameters on every installer invocation. Is that (repetition of the params on every invocation) needed? Of course not. |
||
|
||
it 'allows declaring parameters that should be excluded as command line options' do | ||
config = YAML.load_file(KAFO_CONFIG) | ||
config[:classes] = {:testing => {:exclude => ['version']}} | ||
File.open(KAFO_CONFIG, 'w') do |file| | ||
file.write(config.to_yaml) | ||
end | ||
|
||
code, out, err = run_command '../bin/kafo-configure --full-help' | ||
_(code).must_equal 0, err | ||
_(out).wont_include "--testing-version" | ||
end | ||
end | ||
end | ||
end |
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 standard nomenclature we have been using is
modules
; but what we really seem to specify everywhere are puppet classes not puppet modules. Thus I decided to aim for using the correct representation.