Skip to content

Commit

Permalink
Teach should_run_leapp to check for the CLI option
Browse files Browse the repository at this point in the history
Previously, the check used by blockers to determine if the script will
run leapp was incompatible with the check option as it only read a file
that was written just prior to running stage 1.  This updates the check
to see if we should run leapp to also check to see if the --no-leapp
option was passed via CLI in order to make the sub compatible with the
check option.

Fixes #332
  • Loading branch information
cPholloway committed Jan 9, 2024
1 parent 55850f6 commit f073c1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -6360,7 +6360,9 @@ sub setup_answer_file {
sub should_run_leapp ($self) {

# we store the no_leapp option, but prefer using a positive check instead
my $no_leapp = read_stage_file( 'no_leapp', 0 );
# we need to check to see if the no-leapp option is passed via CLI here too in order
# to allow users to run this script with the '--check --no-leapp' options
my $no_leapp = read_stage_file( 'no_leapp', 0 ) || $self->getopt('no-leapp');
return !$no_leapp;
}

Expand Down
4 changes: 3 additions & 1 deletion script/elevate-cpanel.PL
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,9 @@ sub setup_answer_file {
sub should_run_leapp ($self) {

# we store the no_leapp option, but prefer using a positive check instead
my $no_leapp = read_stage_file( 'no_leapp', 0 );
# we need to check to see if the no-leapp option is passed via CLI here too in order
# to allow users to run this script with the '--check --no-leapp' options
my $no_leapp = read_stage_file( 'no_leapp', 0 ) || $self->getopt('no-leapp');
return !$no_leapp;
}

Expand Down
3 changes: 2 additions & 1 deletion t/leapp_upgrade.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ $mock_elevate->redefine(
setup_answer_file => sub { # cannot use Test::MockFile with system touch...
note "mocked setup_answer_file";
return;
}
},
getopt => sub { return; },
);

my $mock_elevate_file = Test::MockFile->file('/var/cpanel/elevate');
Expand Down

0 comments on commit f073c1f

Please sign in to comment.