1 | <?php |
||
29 | final class DeploymentUtils |
||
30 | { |
||
31 | /** @var array slices for "Blue/Green-Deployment" mechanism */ |
||
32 | private static $slices = ['blue', 'green']; |
||
33 | |||
34 | /** @var bool Indicator to signal an initial deployment */ |
||
35 | private static $isInitial = false; |
||
36 | |||
37 | /** |
||
38 | * Creates mandatory services on CF. |
||
39 | * |
||
40 | * @param Deployment $deploy Command handler. |
||
41 | * @param OutputInterface $output Output of the command |
||
42 | * @param array $configuration Application configuration (read from deploy.yml) |
||
43 | * @param string $applicationName Application to be used |
||
44 | * @param string $slice deployment location in blue/green deployment. |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | 4 | public static function createServices( |
|
81 | |||
82 | /** |
||
83 | * Determines what slice to be used on blue/green deployment. |
||
84 | * |
||
85 | * **NOTICE** |
||
86 | * Behavior on different szenarios |
||
87 | * |
||
88 | * trail | blue | green | deployed |
||
89 | * =================================== |
||
90 | * 1st | n/a | n/a | blue |
||
91 | * 2nd | avail | n/a | green (blue is dropped) |
||
92 | * 3rd | n/a | avail | blue (green is dropped) |
||
93 | * manually | avail | avail | green (blue will be dropped) |
||
94 | * altered | | | |
||
95 | * |
||
96 | * @param Deployment $deploy Command handler. |
||
97 | * @param OutputInterface $output Output of the command |
||
98 | * @param array $configuration Application configuration (read from deploy.yml). |
||
99 | * @param string $applicationName Application to be cleaned up |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | 5 | public static function determineDeploymentSlice( |
|
161 | |||
162 | /** |
||
163 | * Logs in to CF. |
||
164 | * |
||
165 | * @param Deployment $deploy Command handler. |
||
166 | * @param OutputInterface $output Output of the command |
||
167 | * @param array $configuration Application configuration (read from deploy.yml). |
||
168 | * |
||
169 | * @return void |
||
170 | */ |
||
171 | 4 | public static function login(Deployment $deploy, OutputInterface $output, array $configuration) |
|
182 | |||
183 | /** |
||
184 | * Logs off from CF. |
||
185 | * |
||
186 | * @param Deployment $deploy Command handler. |
||
187 | * @param OutputInterface $output Output of the command |
||
188 | * @param array $configuration Application configuration (read from deploy.yml). |
||
189 | * |
||
190 | * @return void |
||
191 | */ |
||
192 | 4 | public static function logout(Deployment $deploy, OutputInterface $output, array $configuration) |
|
203 | |||
204 | /** |
||
205 | * Removes instances of the application not needed anymore. |
||
206 | * |
||
207 | * @param Deployment $deploy Command handler. |
||
208 | * @param OutputInterface $output Output of the command |
||
209 | * @param array $configuration Application configuration (read from deploy.yml). |
||
210 | * @param string $applicationName Application to be cleaned up |
||
211 | * @param string $route Used a the subdomain for the application route. |
||
212 | * @param string $slice Slice to be removed. |
||
213 | * |
||
214 | * @return void |
||
215 | */ |
||
216 | 4 | public static function cleanUp( |
|
246 | |||
247 | /** |
||
248 | * Removes instances of the application not needed anymore. |
||
249 | * |
||
250 | * @param Deployment $deploy Command handler. |
||
251 | * @param OutputInterface $output Output of the command |
||
252 | * @param array $configuration Application configuration (read from deploy.yml). |
||
253 | * @param string $applicationName Application to be cleaned up |
||
254 | * @param string $route Used a the subdomain for the application route. |
||
255 | * @param string $slice Slice to be deployed. |
||
256 | * @param boolean $start Start the deploy automagically |
||
257 | * |
||
258 | * @return void |
||
259 | */ |
||
260 | 4 | public static function deploy( |
|
288 | |||
289 | /** |
||
290 | * Runs a command on a Cloud Foundry instance |
||
291 | * |
||
292 | * @param Deployment $deploy deploy handler |
||
293 | * @param OutputInterface $output output interface |
||
294 | * @param array $configuration the configuration params |
||
295 | * @param string $command the command to be executed |
||
296 | * @param string $applicationName the application name |
||
297 | * |
||
298 | * @return void |
||
299 | */ |
||
300 | public static function runCommand( |
||
329 | |||
330 | /** |
||
331 | * Initializes a single |
||
332 | * |
||
333 | * @param Deployment $deploy Command handler. |
||
334 | * @param OutputInterface $output Output of the command |
||
335 | * @param StepInterface[] $steps Process step to be executed. |
||
336 | * @param string $startMsg Message to be shown on start. |
||
337 | * @param string $endMsg Message to be shown on end. |
||
338 | * @param bool $returnProcessMessage Include message from process in output.. |
||
339 | * @param bool $forceImmediateOutput Forces the process to send every output to stdout immediately. |
||
340 | * |
||
341 | * @return void |
||
342 | */ |
||
343 | 13 | private static function deploySteps( |
|
362 | |||
363 | /** |
||
364 | * Determine if the slice to be deploy |
||
365 | * |
||
366 | * @return bool |
||
367 | */ |
||
368 | 4 | public static function isInitialDeploy() |
|
372 | |||
373 | /** |
||
374 | * Injects specific environment vars to the Cloud Foundry setup. |
||
375 | * |
||
376 | * @param Deployment $deploy Command handler. |
||
377 | * @param OutputInterface $output Output of the command |
||
378 | * @param array $configuration Application configuration (read from deploy.yml). |
||
379 | * @param string $application Application the env vars to be defined in |
||
380 | * |
||
381 | * @return void |
||
382 | */ |
||
383 | 4 | public static function setEnvironmentVariables( |
|
407 | |||
408 | /** |
||
409 | * Adds a new route to the named application |
||
410 | * |
||
411 | * @param Deployment $deploy Command handler. |
||
412 | * @param OutputInterface $output Output of the command |
||
413 | * @param array $configuration Application configuration (read from deploy.yml). |
||
414 | * @param string $applicationName Application to be cleaned up |
||
415 | * @param string $slice Slice to be deployed. |
||
416 | * @param string $route Used a the subdomain for the application route. |
||
417 | * |
||
418 | * @return void |
||
419 | */ |
||
420 | 4 | public static function addRoute( |
|
446 | |||
447 | /** |
||
448 | * Starts the named slice of the provided application. |
||
449 | * |
||
450 | * @param Deployment $deploy Command handler. |
||
451 | * @param OutputInterface $output Output of the command |
||
452 | * @param array $configuration Application configuration (read from deploy.yml). |
||
453 | * @param string $applicationName Application to be cleaned up |
||
454 | * @param string $slice Slice to be deployed.. |
||
455 | * |
||
456 | * @return void |
||
457 | */ |
||
458 | 4 | public static function startApplication( |
|
481 | |||
482 | /** |
||
483 | * Provides the name of the target to used. |
||
484 | * |
||
485 | * @param string $application Name of the current application |
||
486 | * @param string $slice Slice to be used (from blue/green deployment) |
||
487 | * |
||
488 | * @return string |
||
489 | */ |
||
490 | 8 | private static function renderTargetName($application, $slice) |
|
494 | } |
||
495 |