|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace TheAentMachine\AentGitLabCI\Event; |
|
4
|
|
|
|
|
5
|
|
|
use TheAentMachine\Aent\Event\CI\AbstractCIConfigureCIEvent; |
|
6
|
|
|
use TheAentMachine\AentGitLabCI\Event\Model\Configure; |
|
7
|
|
|
use TheAentMachine\Prompt\Helper\ValidatorHelper; |
|
8
|
|
|
|
|
9
|
|
|
final class ConfigureCIEvent extends AbstractCIConfigureCIEvent |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @return array<string,string> |
|
13
|
|
|
*/ |
|
14
|
|
|
protected function getMetadata(): array |
|
15
|
|
|
{ |
|
16
|
|
|
$registryDomainName = $this->getRegistryDomainName(); |
|
17
|
|
|
$projectGroup = $this->getProjectGroup(); |
|
18
|
|
|
$projectName = $this->getProjectName(); |
|
19
|
|
|
$configure = new Configure($registryDomainName, $projectGroup, $projectName); |
|
20
|
|
|
return $configure->toArray(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @return string |
|
25
|
|
|
*/ |
|
26
|
|
|
private function getRegistryDomainName(): string |
|
27
|
|
|
{ |
|
28
|
|
|
$text = "\nYour registry URL"; |
|
29
|
|
|
$helpText = "The URL of the <info>Docker Container Registry</info> integrated with your Git repository on your <info>GitLab</info>. This is the space where your Docker images are stored."; |
|
30
|
|
|
return $this->prompt->input($text, $helpText, null, true, ValidatorHelper::getDomainNameWithPortValidator()) ?? ''; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @return string |
|
35
|
|
|
*/ |
|
36
|
|
|
private function getProjectGroup(): string |
|
37
|
|
|
{ |
|
38
|
|
|
$text = "\nYour project group"; |
|
39
|
|
|
$helpText = "The group defined in the project path on <info>GitLab</info>. For instance, a project with URL https://git.yourcompany.com/foo/bar has <info>foo</info> as group name."; |
|
40
|
|
|
return $this->prompt->input($text, $helpText, null, true, ValidatorHelper::getAlphaWithAdditionalCharactersValidator(['-'])) ?? ''; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return string |
|
45
|
|
|
*/ |
|
46
|
|
|
private function getProjectName(): string |
|
47
|
|
|
{ |
|
48
|
|
|
$text = "\nYour project name"; |
|
49
|
|
|
$helpText = "The name defined in the project path on <info>GitLab</info>. For instance, a project with URL https://git.yourcompany.com/foo/bar has <info>bar</info> as project name."; |
|
50
|
|
|
return $this->prompt->input($text, $helpText, null, true, ValidatorHelper::getAlphaWithAdditionalCharactersValidator(['-'])) ?? ''; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|