NEW FEATURE: multiple wrong exit statuses

This commit is contained in:
Jeroen De Meerleer 2021-05-28 15:00:24 +02:00
parent 1210c0193f
commit 4987f818c5
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
4 changed files with 9 additions and 8 deletions

View File

@ -32,7 +32,7 @@ class JobController extends Controller
if($this->getRequest()->getMethod() == 'GET') {
$job = $jobRepo->getJob($id);
$runs = $runRepo->getRunsForJob($id, $all != 'all' ? [$job['data']['response']] : []);
$runs = $runRepo->getRunsForJob($id, $all != 'all' ? array_merge($job['data']['response'] ?? [], $job['data']['http-status'] ?? []) : []);
return $this->render('job/view.html.twig', ['job' => $job, 'runs' => $runs, 'allruns' => $all == 'all']);
} elseif($this->getRequest()->getMethod() == 'DELETE') {
$success = $jobRepo->deleteJob($id);

View File

@ -266,7 +266,7 @@ class Job extends Repository
{
case 'command':
$values['data']['command'] = $values['command'];
$values['data']['response'] = $values['response'];
$values['data']['response'] = explode(',', $values['response']);
break;
case 'reboot':
$values['data']['reboot-command'] = $values['reboot-command'];
@ -287,7 +287,7 @@ class Job extends Repository
case 'http':
$parsedUrl = parse_url($values['url']);
$values['data']['url'] = $values['url'];
$values['data']['response'] = $values['response'];
$values['data']['http-status'] = explode(',', $values['http-status']);
$values['data']['basicauth-username'] = $values['basicauth-username'];
if(empty($parsedUrl['host'])) {
throw new \InvalidArgumentException('Some data was invalid');

View File

@ -13,12 +13,13 @@ class Run extends Repository
$runsSql = "SELECT * FROM run WHERE job_id = :job";
$params = [':job' => $id];
if (!empty($excludedexitcodes)) {
$runsSql .= ' AND exitcode NOT in (';
$runsSql .= ' AND exitcode NOT in ';
$exitcodes = [];
foreach($excludedexitcodes as $key => $exitcode) {
$runsSql .= ':code' . $key;
$exitcodes[] = ':code' . $key;
$params[':code' . $key] = $exitcode;
}
$runsSql .= ')';
$runsSql .= '(' . implode(',', $exitcodes) . ')';
}
if ($ordered) $runsSql .= ' ORDER by timestamp DESC';
$runsStmt = $this->dbcon->prepare($runsSql);

View File

@ -152,8 +152,8 @@
</div>
<div class="mb-3">
<label for="response">Expected response status code</label>
<input type="text" name="response" class="form-control" id="response" placeholder="200" value="{% if attribute(data, 'response') is not empty %}{{ attribute(data, 'response') }}{% endif %}">
<label for="http-status">Expected http status code</label>
<input type="text" name="http-status" class="form-control" id="http-status" placeholder="200" value="{% if attribute(data, 'http-status') is not empty %}{{ attribute(data, 'http-status') }}{% endif %}">
</div>
</div>