Skip to content

Commit

Permalink
GL-3134: Add new Gitlab variable for Node projects. (#1818)
Browse files Browse the repository at this point in the history
* GL-3134: Add new Gitlab variable for Node projects.

* GL-3134: Update tests for NODE_HOSTING_TYPE.

---------

Co-authored-by: Dane Powell <[email protected]>
  • Loading branch information
bemarlan and danepowell authored Oct 23, 2024
1 parent befc2dc commit 59fe530
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/Command/CodeStudio/CodeStudioCiCdVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function getList(): array
/**
* @return array<mixed>
*/
public static function getDefaultsForNode(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $nodeVersion = null): array
public static function getDefaultsForNode(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $nodeVersion = null, ?string $nodeHosting = null): array
{
return [
[
Expand Down Expand Up @@ -63,6 +63,13 @@ public static function getDefaultsForNode(?string $cloudApplicationUuid = null,
'value' => $nodeVersion,
'variable_type' => 'env_var',
],
[
'key' => 'NODE_HOSTING_TYPE',
'masked' => false,
'protected' => false,
'value' => $nodeHosting,
'variable_type' => 'env_var',
],
];
}

Expand Down
7 changes: 4 additions & 3 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$nodeVersion = null;
$projectType = $this->getListOfProjectType();
$projectSelected = $this->io->choice('Select a project type', $projectType, "Drupal_project");
$nodeHosting = "basic";

switch ($projectSelected) {
case "Drupal_project":
Expand Down Expand Up @@ -128,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
];
$client = $this->getGitLabClient();
$client->projects()->update($project['id'], $parameters);
$this->setGitLabCiCdVariablesForNodeProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion);
$this->setGitLabCiCdVariablesForNodeProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion, $nodeHosting);
break;
}

Expand Down Expand Up @@ -241,10 +242,10 @@ private function setGitLabCiCdVariablesForPhpProject(array $project, string $clo
}
}

private function setGitLabCiCdVariablesForNodeProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $nodeVersion): void
private function setGitLabCiCdVariablesForNodeProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $nodeVersion, string $nodeHosting): void
{
$this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}..");
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForNode($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion);
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForNode($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion, $nodeHosting);
$gitlabCicdExistingVariables = $this->gitLabClient->projects()
->variables($project['id']);
$gitlabCicdExistingVariablesKeyed = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testGetDefaultsForNode(): void
protected function testBooleanValues(array $variables): void
{
foreach ($variables as $variable) {
if ($variable['key'] !== "PHP_VERSION" && $variable['key'] !== "NODE_VERSION") {
if ($variable['key'] !== "PHP_VERSION" && $variable['key'] !== "NODE_VERSION" && $variable['key'] !== "NODE_HOSTING_TYPE") {
$maskedValue = $variable['masked'];
$this->assertEquals(true, $maskedValue);
} else {
Expand Down

0 comments on commit 59fe530

Please sign in to comment.