Skip to content

Commit ce89a30

Browse files
committed
Fixes #33577 - Only enable Foreman Puppet plugin with Foreman
If the user passed in --no-enable-foreman then the Foreman plugin should not be enabled. The same is true for the CLI side of it. The add-cli migration is changed to respect an already present option that is false in order to properly test this change.
1 parent e56d06d commit ce89a30

File tree

7 files changed

+60
-4
lines changed

7 files changed

+60
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This fixes up 20210803130619_add_hammer_puppet_plugin.rb in case foreman::cli
2+
# is disabled
3+
if answers['foreman::cli::puppet'] && !answers['foreman::cli']
4+
answers['foreman::cli::puppet'] = false
5+
end
6+
# This fixes up 20210708144320_add_foreman_puppet.rb in case foreman is
7+
# disabled
8+
if answers['foreman::plugin::puppet'] && !answers['foreman']
9+
answers['foreman::plugin::puppet'] = false
10+
end
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
answers['foreman::cli'] ||= true
1+
unless answers.key?('foreman::cli')
2+
answers['foreman::cli'] = true
3+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This fixes up 20210803130619-add-hammer-puppet-plugin.rb in case foreman::cli
2+
# is disabled
3+
if answers['foreman::cli::puppet'] && !answers['foreman::cli']
4+
answers['foreman::cli::puppet'] = false
5+
end
6+
# This fixes up 210708144422-add-foreman-puppet.rb in case foreman is
7+
# disabled
8+
if answers['foreman::plugin::puppet'] && !answers['foreman']
9+
answers['foreman::plugin::puppet'] = false
10+
end

spec/fixtures/pulpcore-migration-dont-use-content-plugins-on-upgrades/katello-answers-after.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ foreman::plugin::kubevirt: false
2121
foreman::plugin::leapp: false
2222
foreman::plugin::memcache: false
2323
foreman::plugin::monitoring: false
24-
foreman::plugin::puppet: true
24+
foreman::plugin::puppet: false
2525
foreman::plugin::remote_execution: true
2626
foreman::plugin::remote_execution::cockpit: false
2727
foreman::plugin::rh_cloud: false

spec/fixtures/pulpcore-migration-rpm-only/katello-answers-after.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ foreman::plugin::kubevirt: false
2121
foreman::plugin::leapp: false
2222
foreman::plugin::memcache: false
2323
foreman::plugin::monitoring: false
24-
foreman::plugin::puppet: true
24+
foreman::plugin::puppet: false
2525
foreman::plugin::remote_execution: true
2626
foreman::plugin::remote_execution::cockpit: false
2727
foreman::plugin::rh_cloud: false

spec/fixtures/pulpcore-migration/katello-answers-after.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ foreman::plugin::kubevirt: false
2121
foreman::plugin::leapp: false
2222
foreman::plugin::memcache: false
2323
foreman::plugin::monitoring: false
24-
foreman::plugin::puppet: true
24+
foreman::plugin::puppet: false
2525
foreman::plugin::remote_execution: true
2626
foreman::plugin::remote_execution::cockpit: false
2727
foreman::plugin::rh_cloud: false

spec/migration_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,38 @@
142142
end
143143
end
144144
end
145+
146+
context 'disable puppet if needed' do
147+
%w[foreman katello].each do |scenario_name|
148+
context "on #{scenario_name}" do
149+
let(:answers) do
150+
{
151+
'foreman' => false,
152+
'foreman::cli' => false,
153+
}
154+
end
155+
let(:scenario_name) { scenario_name }
156+
let(:config) { load_config_yaml("#{scenario_name}.yaml") }
157+
let(:migrations) { config_path("#{scenario_name}.migrations") }
158+
let(:migrator) { Kafo::Migrations.new(migrations).run(config, answers) }
159+
subject(:migrated_answers) { migrator[1] }
160+
161+
it 'keeps foreman::cli disabled' do
162+
expect(migrated_answers['foreman::cli']).to be false
163+
end
164+
165+
it 'adds foreman::cli::puppet disabled' do
166+
expect(migrated_answers['foreman::cli::puppet']).to be false
167+
end
168+
169+
it 'keeps foreman disabled' do
170+
expect(migrated_answers['foreman']).to be false
171+
end
172+
173+
it 'adds foreman::plugin::puppet disabled' do
174+
expect(migrated_answers['foreman::plugin::puppet']).to be false
175+
end
176+
end
177+
end
178+
end
145179
end

0 commit comments

Comments
 (0)