Skip to content

Commit

Permalink
Add option to download package updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Apr 11, 2024
1 parent 6482b2b commit 0bfd9f4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
38 changes: 31 additions & 7 deletions definitions/scenarios/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Update < ForemanMaintain::Scenario
description 'update packages in unlocked session'
param :packages, 'List of packages to Update', :array => true
param :assumeyes, 'Do not ask for confirmation'
param :downloadonly, 'Download and cache packages'
manual_detection
end

Expand All @@ -105,14 +106,37 @@ def compose
add_step_with_context(Procedures::Packages::Update,
:force => true, :warn_on_errors => true)
else
add_steps_with_context(
Procedures::Packages::UpdateAllConfirmation,
Procedures::Packages::InstallerConfirmation
)
unless context.get(:downloadonly)
add_steps_with_context(
Procedures::Packages::UpdateAllConfirmation,
Procedures::Packages::InstallerConfirmation
)
end

add_step_with_context(Procedures::Packages::UnlockVersions)
add_step_with_context(Procedures::Packages::Update,
:force => true, :warn_on_errors => true)
add_step_with_context(Procedures::Installer::Run)

if context.get(:downloadonly)
add_step_with_context(
Procedures::Packages::Update,
:force => true,
:warn_on_errors => true,
:dnf_options => ['--downloadonly'],

Check failure on line 123 in definitions/scenarios/packages.rb

View workflow job for this annotation

GitHub Actions / rubocop / Rubocop

Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.
)
else
add_step_with_context(
Procedures::Packages::Update,
:force => true,
:warn_on_errors => true
)
end


Check failure on line 133 in definitions/scenarios/packages.rb

View workflow job for this annotation

GitHub Actions / rubocop / Rubocop

Layout/EmptyLines: Extra blank line detected.
if context.get(:downloadonly)
add_step_with_context(Procedures::Packages::LockVersions)
else
add_step_with_context(Procedures::Installer::Run)
end

add_step(Procedures::Packages::LockingStatus)
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/foreman_maintain/cli/packages_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ def execute
subcommand 'update', 'Update packages in an unlocked session' do
interactive_option(['assumeyes'])
parameter '[PACKAGES] ...', 'packages to update', :attribute_name => :packages
option '--downloadonly', :flag, 'Downloads and caches package updates only', :default => false

Check failure on line 58 in lib/foreman_maintain/cli/packages_command.rb

View workflow job for this annotation

GitHub Actions / rubocop / Rubocop

Layout/LineLength: Line is too long. [102/100]

def execute
run_scenarios_and_exit(
Scenarios::Packages::Update.new(
:packages => packages,
:assumeyes => assumeyes?
:assumeyes => assumeyes?,
:downloadonly => @downloadonly
)
)
end
Expand Down

0 comments on commit 0bfd9f4

Please sign in to comment.