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

Simplify CLI::monitor with 'all' function #5485

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
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
Loading