1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Step to deletes an application from a Cloud Foundry instance. |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Graviton\Deployment\Steps\CloudFoundry; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @author List of contributors <https://github.com/libgraviton/deploy-scripts/graphs/contributors> |
10
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
11
|
|
|
* @link http://swisscom.ch |
12
|
|
|
*/ |
13
|
|
|
final class StepDelete extends AbstractStep |
14
|
|
|
{ |
15
|
|
|
/** @var string deployment location in blue/green deployment. */ |
16
|
|
|
private $slice; |
17
|
|
|
|
18
|
|
|
/** @var string Name of the CF-application to be deleted */ |
19
|
|
|
private $applicationName; |
20
|
|
|
|
21
|
|
|
/** @var bool */ |
22
|
|
|
private $delMappedRoutes; |
23
|
|
|
|
24
|
|
|
/** @var bool Flag to force a deletion or not. */ |
25
|
|
|
private $force; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* |
29
|
|
|
* @param array $configuration Current application configuration. |
30
|
|
|
* @param string $applicationName Name of the CF-application to be deleted. |
31
|
|
|
* @param string $slice deployment location in blue/green deployment. |
32
|
|
|
* @param bool $force Flag to force a deletion or not. |
33
|
|
|
* @param bool $deleteMappedRoutes Flag to delete mapped routes as well or not. |
34
|
|
|
* |
35
|
|
|
* @link http://martinfowler.com/bliki/BlueGreenDeployment.html |
36
|
|
|
*/ |
37
|
8 |
|
public function __construct( |
38
|
|
|
array $configuration, |
39
|
|
|
$applicationName, |
40
|
|
|
$slice, |
41
|
|
|
$force = false, |
42
|
|
|
$deleteMappedRoutes = false |
43
|
|
|
) { |
44
|
8 |
|
parent::__construct($configuration); |
45
|
|
|
|
46
|
8 |
|
$this->slice = $slice; |
47
|
8 |
|
$this->applicationName = $applicationName; |
48
|
8 |
|
$this->force = ($force !== false); |
49
|
8 |
|
$this->delMappedRoutes = ($deleteMappedRoutes !== false); |
50
|
8 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* returns the command |
54
|
|
|
* |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
7 |
|
public function getCommand() |
58
|
|
|
{ |
59
|
|
|
$command = array( |
60
|
7 |
|
$this->configuration['cf_bin'], |
61
|
7 |
|
'delete', |
62
|
7 |
|
$this->applicationName . '-' . $this->slice |
63
|
7 |
|
); |
64
|
|
|
|
65
|
7 |
|
if ($this->force === true) { |
66
|
5 |
|
$command[] = '-f'; |
67
|
5 |
|
} |
68
|
|
|
|
69
|
7 |
|
if ($this->delMappedRoutes === true) { |
70
|
2 |
|
$command[] = '-r'; |
71
|
2 |
|
} |
72
|
|
|
|
73
|
7 |
|
return $command; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|