1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\NewRelic\Communication\Console; |
9
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Communication\Console\Console; |
11
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @method \SprykerEco\Zed\NewRelic\Business\NewRelicFacadeInterface getFacade() |
17
|
|
|
*/ |
18
|
|
|
class RecordDeploymentConsole extends Console |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected const COMMAND_NAME = 'newrelic:record-deployment'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected const DESCRIPTION = 'Send deployment notification to New Relic'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected const ARGUMENT_APPLICATION_NAME = 'app_name'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected const ARGUMENT_APPLICATION_NAME_DESCRIPTION = 'The name of the application in New Relic'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected const ARGUMENT_USER = 'user'; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected const ARGUMENT_USER_DESCRIPTION = 'The name of the deployer'; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string |
52
|
|
|
*/ |
53
|
|
|
protected const ARGUMENT_REVISION = 'revision'; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
*/ |
58
|
|
|
protected const ARGUMENT_REVISION_DESCRIPTION = 'Revision number'; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var string |
62
|
|
|
*/ |
63
|
|
|
protected const ARGUMENT_DESCRIPTION = 'description'; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var string |
67
|
|
|
*/ |
68
|
|
|
protected const ARGUMENT_DESCRIPTION_DESCRIPTION = 'Deployment description'; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var string |
72
|
|
|
*/ |
73
|
|
|
protected const ARGUMENT_CHANGELOG = 'changelog'; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var string |
77
|
|
|
*/ |
78
|
|
|
protected const ARGUMENT_CHANGELOG_DESCRIPTION = 'Change log'; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return void |
82
|
|
|
*/ |
83
|
|
|
protected function configure(): void |
84
|
|
|
{ |
85
|
|
|
parent::configure(); |
86
|
|
|
|
87
|
|
|
$this->setName(static::COMMAND_NAME); |
88
|
|
|
$this->setDescription(static::DESCRIPTION); |
89
|
|
|
|
90
|
|
|
$this->addArgument( |
91
|
|
|
static::ARGUMENT_APPLICATION_NAME, |
92
|
|
|
InputArgument::REQUIRED, |
93
|
|
|
static::ARGUMENT_APPLICATION_NAME_DESCRIPTION, |
94
|
|
|
); |
95
|
|
|
|
96
|
|
|
$this->addArgument( |
97
|
|
|
static::ARGUMENT_USER, |
98
|
|
|
InputArgument::REQUIRED, |
99
|
|
|
static::ARGUMENT_USER_DESCRIPTION, |
100
|
|
|
); |
101
|
|
|
|
102
|
|
|
$this->addArgument( |
103
|
|
|
static::ARGUMENT_REVISION, |
104
|
|
|
InputArgument::REQUIRED, |
105
|
|
|
static::ARGUMENT_REVISION_DESCRIPTION, |
106
|
|
|
); |
107
|
|
|
|
108
|
|
|
$this->addArgument( |
109
|
|
|
static::ARGUMENT_DESCRIPTION, |
110
|
|
|
InputArgument::OPTIONAL, |
111
|
|
|
static::ARGUMENT_DESCRIPTION_DESCRIPTION, |
112
|
|
|
); |
113
|
|
|
|
114
|
|
|
$this->addArgument( |
115
|
|
|
static::ARGUMENT_CHANGELOG, |
116
|
|
|
InputArgument::OPTIONAL, |
117
|
|
|
static::ARGUMENT_CHANGELOG_DESCRIPTION, |
118
|
|
|
); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
123
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
124
|
|
|
* |
125
|
|
|
* @return int |
126
|
|
|
*/ |
127
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
128
|
|
|
{ |
129
|
|
|
$this->getMessenger()->info(sprintf( |
130
|
|
|
'Send deployment notification to New Relic for %s', |
131
|
|
|
$input->getArgument(static::ARGUMENT_APPLICATION_NAME), |
132
|
|
|
)); |
133
|
|
|
|
134
|
|
|
$arguments = $input->getArguments(); |
135
|
|
|
unset($arguments['command']); |
136
|
|
|
|
137
|
|
|
$this->getFacade()->recordDeployment($arguments); |
138
|
|
|
|
139
|
|
|
return 0; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|