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

Update packages update all warning #883

Merged
merged 1 commit into from
Jun 13, 2024
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
17 changes: 12 additions & 5 deletions definitions/procedures/packages/update_all_confirmation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ class UpdateAllConfirmation < ForemanMaintain::Procedure

def run
if @packages.nil? || @packages.empty?
question = "\nWARNING: No specific packages to update were provided\n" \
"so we are going to update all available packages.\n" \
"To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \
"Do you want to proceed with update of everything regardless\n" \
'of the recommendations?'
command = ForemanMaintain.command_name

question = <<~MSG
WARNING: No specific packages to update were provided
so we are going to update all available packages. We
recommend using the update command to update to a minor
version and/or operating system using '#{command} update'.
To upgrade to the next #{feature(:instance).product_name} version use '#{command} upgrade'.
Do you want to proceed with update of everything regardless of
the recommendations?
MSG

answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
abort! unless answer == :yes
end
Expand Down
4 changes: 4 additions & 0 deletions lib/foreman_maintain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ def pkg_and_cmd_name
[main_package_name, 'foreman-maintain']
end

def command_name
pkg_and_cmd_name[1]
end

def perform_self_upgrade
package_name, command = pkg_and_cmd_name

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'test_helper'
require_relative '../../test_helper'
require_relative '../../../../definitions/procedures/packages/update_all_confirmation'

describe Procedures::Packages::UpdateAllConfirmation do
include ::DefinitionsTestHelper

def skip_mock_package_manager
true
end

subject do
Procedures::Packages::UpdateAllConfirmation.new
end

it 'contains the proper message for Foreman' do
assume_feature_present(:foreman_install)

question = <<~MSG
WARNING: No specific packages to update were provided
so we are going to update all available packages. We
recommend using the update command to update to a minor
version and/or operating system using 'foreman-maintain update'.
To upgrade to the next Foreman version use 'foreman-maintain upgrade'.
Do you want to proceed with update of everything regardless of
the recommendations?
MSG

subject.expects(:ask_decision).with(question, :actions_msg => "y(yes), q(quit)").returns(:yes)

run_procedure(subject)
end

it 'contains the proper message for Satellite' do
assume_feature_present(:satellite)

question = <<~MSG
WARNING: No specific packages to update were provided
so we are going to update all available packages. We
recommend using the update command to update to a minor
version and/or operating system using 'satellite-maintain update'.
To upgrade to the next Satellite version use 'satellite-maintain upgrade'.
Do you want to proceed with update of everything regardless of
the recommendations?
MSG

subject.expects(:ask_decision).with(question, :actions_msg => "y(yes), q(quit)").returns(:yes)

run_procedure(subject)
end
end
Loading