Skip to content

Commit

Permalink
Simplify CLI::monitor with 'all' function
Browse files Browse the repository at this point in the history
  • Loading branch information
okurz committed Feb 26, 2024
1 parent 1a01d2d commit 93b7250
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/OpenQA/CLI/monitor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package OpenQA::CLI::monitor;
use Mojo::Base 'OpenQA::Command', -signatures;

use OpenQA::Jobs::Constants;
use List::Util qw(all);
use Mojo::Util qw(encode getopt);

has description => 'Monitors a set of jobs';
Expand All @@ -28,10 +29,7 @@ sub _monitor_jobs ($self, $client, $poll_interval, $job_ids, $job_results) {
}

sub _compute_return_code ($self, $job_results) {
for my $job_result (@$job_results) {
return 2 unless OpenQA::Jobs::Constants::is_ok_result($job_result);
}
return 0;
all { OpenQA::Jobs::Constants::is_ok_result($_) } @$job_results ? 0 : 2;
}

sub _monitor_and_return ($self, $client, $poll_interval, $job_ids) {
Expand Down

0 comments on commit 93b7250

Please sign in to comment.