Skip to content
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

Remove legacy code from installer feature #748

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 8 additions & 66 deletions definitions/features/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@ class Features::Installer < ForemanMaintain::Feature
label :installer

confine do
find_package('foreman-installer') ||
find_package('katello-installer') ||
find_package('capsule-installer')
find_package('foreman-installer')
end
end

def initialize
@installer_type = if find_package('foreman-installer')
:scenarios
elsif find_package('katello-installer')
:legacy_katello
elsif find_package('capsule-installer')
:legacy_capsule
end
end

def answers
load_answers(configuration)
end
Expand All @@ -28,39 +16,17 @@ def configuration
end

def config_file
case @installer_type
when :scenarios
last_scenario_config
when :legacy_katello
File.join(config_directory, 'katello-installer.yaml')
when :legacy_capsule
File.join(config_directory, 'capsule-installer.yaml')
end
end

def with_scenarios?
@installer_type == :scenarios
last_scenario_config
end

def config_directory
case @installer_type
when :scenarios
'/etc/foreman-installer'
when :legacy_katello
'/etc/katello-installer'
when :legacy_capsule
'/etc/capsule-installer'
end
'/etc/foreman-installer'
end

def custom_hiera_file
@custom_hiera_file ||= File.join(config_directory, 'custom-hiera.yaml')
end

def can_upgrade?
@installer_type == :scenarios || @installer_type == :legacy_katello
end

def config_files
Dir.glob(File.join(config_directory, '**/*')) +
[
Expand All @@ -71,23 +37,14 @@ def config_files
end

def last_scenario
return nil unless with_scenarios?

File.basename(last_scenario_config).split('.')[0]
end

def installer_command
case @installer_type
when :scenarios
if feature(:satellite)
'satellite-installer'
else
'foreman-installer'
end
when :legacy_katello
'katello-installer'
when :legacy_capsule
'capsule-installer'
if feature(:satellite)
'satellite-installer'
else
'foreman-installer'
end
end

Expand All @@ -105,22 +62,7 @@ def run_with_status(arguments = '', exec_options = {})
end

def upgrade(exec_options = {})
run(installer_arguments, exec_options)
end

def installer_arguments
installer_args = ''

if feature(:foreman_proxy)&.with_content? &&
check_max_version('foreman-installer', '3.4')
installer_args += ' --disable-system-checks'
end

if !check_min_version('foreman-installer', '2.1') && can_upgrade?
installer_args += ' --upgrade'
end

installer_args
run('', exec_options)
end

def initial_admin_username
Expand Down
30 changes: 0 additions & 30 deletions test/definitions/features/installer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
before do
installer_config_dir(["#{data_dir}/installer/simple_config"])
mock_installer_package('foreman-installer')
Features::Installer.any_instance.
stubs(:installer_arguments).returns('--disable-system-checks --upgrade')
end

it 'loads list of configs on the start' do
Expand All @@ -28,10 +26,6 @@
_(subject.config_files.sort).must_equal(expected_config_files)
end

it 'can tell if we use scenarios or not' do
_(subject.with_scenarios?).must_equal true
end

it 'can tell last used scenario from the link' do
_(subject.last_scenario).must_equal('foreman')
end
Expand All @@ -40,30 +34,6 @@
_(subject.answers['foreman']['admin_password']).must_equal('inspasswd')
end

it 'has --upgrade' do
_(subject.can_upgrade?).must_equal true
end

context '#upgrade' do
it '#upgrade runs the installer with correct params' do
assume_feature_absent(:satellite)
installer_inst.expects(:'execute!').
with('foreman-installer --disable-system-checks --upgrade',
{ :interactive => true }).
returns(true)
subject.upgrade(:interactive => true)
end

it '#upgrade runs the installer with correct params in satellite' do
assume_feature_present(:satellite)
installer_inst.expects(:'execute!').
with('satellite-installer --disable-system-checks --upgrade',
{ :interactive => true }).
returns(true)
subject.upgrade(:interactive => true)
end
end

context '#run' do
it 'runs the installer with correct params' do
assume_feature_absent(:satellite)
Expand Down
Loading