Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 3178307

Browse files
author
Sven Speckmaier
committed
catch no schedule configured exception
1 parent 4f1d3c7 commit 3178307

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

plugin/PhpCliBlueprint/PhpCliBlueprint.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use Closure;
44
use Rancherize\Blueprint\Blueprint;
55
use Rancherize\Blueprint\Cron\CronService\CronService;
6+
use Rancherize\Blueprint\Cron\Schedule\Exceptions\NoScheduleConfiguredException;
67
use Rancherize\Blueprint\Cron\Schedule\ScheduleParser;
78
use Rancherize\Blueprint\Flags\HasFlagsTrait;
89
use Rancherize\Blueprint\Infrastructure\Dockerfile\Dockerfile;
@@ -155,17 +156,7 @@ public function build( Configuration $configuration, string $environment, string
155156
$service = $this->makeServerService($config, $projectConfigurable);
156157
$infrastructure->addService($service);
157158

158-
/**
159-
* @var ScheduleParser $scheduleParser
160-
*/
161-
$scheduleParser = container('schedule-parser');
162-
$schedule = $scheduleParser->parseSchedule($config);
163-
164-
/**
165-
* @var CronService $cronService
166-
*/
167-
$cronService = container('cron-service');
168-
$cronService->makeCron($service, $schedule);
159+
$this->parseCronSchedule( $config, $service );
169160

170161
return $infrastructure;
171162
}
@@ -295,4 +286,26 @@ private function addAll(array $configs, string $label, Closure $closure) {
295286
$closure($name, $value);
296287
}
297288
}
289+
290+
/**
291+
* @param $config
292+
* @param $service
293+
*/
294+
protected function parseCronSchedule( $config, $service ) {
295+
/**
296+
* @var ScheduleParser $scheduleParser
297+
*/
298+
$scheduleParser = container( 'schedule-parser' );
299+
try {
300+
$schedule = $scheduleParser->parseSchedule( $config );
301+
} catch ( NoScheduleConfiguredException $e) {
302+
return;
303+
}
304+
305+
/**
306+
* @var CronService $cronService
307+
*/
308+
$cronService = container( 'cron-service' );
309+
$cronService->makeCron( $service, $schedule );
310+
}
298311
}

0 commit comments

Comments
 (0)