Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GL-3133: Add prompt for NODE_HOSTING_TYPE. #1848

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 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, ?string $nodeHosting = 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 $nodeHostingType = null): array
{
return [
[
Expand Down Expand Up @@ -67,7 +67,7 @@ public static function getDefaultsForNode(?string $cloudApplicationUuid = null,
'key' => 'NODE_HOSTING_TYPE',
'masked' => false,
'protected' => false,
'value' => $nodeHosting,
'value' => $nodeHostingType,
'variable_type' => 'env_var',
],
];
Expand Down
14 changes: 10 additions & 4 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->reAuthenticate($cloudKey, $cloudSecret, $this->cloudCredentials->getBaseUri(), $this->cloudCredentials->getAccountsUri());
$phpVersion = null;
$nodeVersion = null;
$nodeHostingType = null;
$projectType = $this->getListOfProjectType();
$projectSelected = $this->io->choice('Select a project type', $projectType, "Drupal_project");
$nodeHosting = "basic";

switch ($projectSelected) {
case "Drupal_project":
Expand All @@ -62,6 +62,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$phpVersion = $phpVersions[$project];
break;
case "Node_project":
$nodeHostingTypes = [
'advanced' => "Advanced Frontend Hosting",
'basic' => "Basic Frontend Hosting",
];
$project = $this->io->choice('Select a NODE hosting type', array_values($nodeHostingTypes), "Basic Frontend Hosting");
$nodeHostingType = array_search($project, $nodeHostingTypes, true);
$nodeVersions = [
'NODE_version_18' => "18",
'NODE_version_20' => "20",
Expand Down Expand Up @@ -129,7 +135,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, $nodeHosting);
$this->setGitLabCiCdVariablesForNodeProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion, $nodeHostingType);
break;
}

Expand Down Expand Up @@ -242,10 +248,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, string $nodeHosting): void
private function setGitLabCiCdVariablesForNodeProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $nodeVersion, string $nodeHostingType): void
{
$this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}..");
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForNode($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion, $nodeHosting);
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForNode($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $nodeVersion, $nodeHostingType);
$gitlabCicdExistingVariables = $this->gitLabClient->projects()
->variables($project['id']);
$gitlabCicdExistingVariablesKeyed = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,52 @@ public static function providerTestCommand(): array
[
// Select a project type Node_project.
'1',
// Select NODE hosting type advanced.
'0',
// Select NODE version 18.
'0',
// Do you want to continue?
'y',
// Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]:
'y',
],
// Args.
[
'--key' => self::$key,
'--secret' => self::$secret,
],
],
[
// No projects.
[],
// Inputs.
[
// Select a project type Node_project.
'1',
// Select NODE hosting type advanced.
'0',
// Select NODE version 20.
'1',
// Do you want to continue?
'y',
// Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]:
'y',
],
// Args.
[
'--key' => self::$key,
'--secret' => self::$secret,
],
],
[
// No projects.
[],
// Inputs.
[
// Select a project type Node_project.
'1',
// Select NODE hosting type basic.
'1',
// Select NODE version 18.
'0',
// Do you want to continue?
Expand All @@ -173,6 +219,8 @@ public static function providerTestCommand(): array
[
// Select a project type Node_project.
'1',
// Select NODE hosting type basic.
'1',
// Select NODE version 20.
'1',
// Do you want to continue?
Expand Down Expand Up @@ -236,6 +284,8 @@ public static function providerTestCommand(): array
self::$secret,
// Select a project type Node_project.
'1',
// Select NODE hosting type basic.
'1',
// Select NODE version 18.
'0',
// Do you want to continue?
Expand Down Expand Up @@ -274,6 +324,8 @@ public static function providerTestCommand(): array
self::$secret,
// Select a project type Node_project.
'1',
// Select NODE hosting type basic.
'1',
// Select NODE version 20.
'1',
// Do you want to continue?
Expand Down
Loading