Skip to content

GL-3695: Add MySQL version prompt for cs:wizard. #1864

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion src/Command/CodeStudio/CodeStudioCiCdVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function getDefaultsForNode(?string $cloudApplicationUuid = null,
/**
* @return array<mixed>
*/
public static function getDefaultsForPhp(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $phpVersion = null): array
public static function getDefaultsForPhp(?string $cloudApplicationUuid = null, ?string $cloudKey = null, ?string $cloudSecret = null, ?string $projectAccessTokenName = null, ?string $projectAccessToken = null, ?string $mysqlVersion = null, ?string $phpVersion = null): array
{
return [
[
Expand Down Expand Up @@ -114,6 +114,13 @@ public static function getDefaultsForPhp(?string $cloudApplicationUuid = null, ?
'value' => $projectAccessToken,
'variable_type' => 'env_var',
],
[
'key' => 'MYSQL_VERSION',
'masked' => false,
'protected' => false,
'value' => $mysqlVersion,
'variable_type' => 'env_var',
],
[
'key' => 'PHP_VERSION',
'masked' => false,
Expand Down
14 changes: 11 additions & 3 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// But, we specifically need an API Token key-pair of Code Studio.
// So we reauthenticate to be sure we're using the provided credentials.
$this->reAuthenticate($cloudKey, $cloudSecret, $this->cloudCredentials->getBaseUri(), $this->cloudCredentials->getAccountsUri());
$mysqlVersion = null;
$phpVersion = null;
$nodeVersion = null;
$nodeHostingType = null;
Expand All @@ -52,6 +53,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int

switch ($projectSelected) {
case "Drupal_project":
$mysqlVersions = [
'MYSQL_version_5.7' => "5.7",
'MYSQL_version_8.0' => "8.0",
];
$project = $this->io->choice('Select a MySQL version', array_values($mysqlVersions), "8.0");
$project = array_search($project, $mysqlVersions, true);
$mysqlVersion = $mysqlVersions[$project];
$phpVersions = [
'PHP_version_8.1' => "8.1",
'PHP_version_8.2' => "8.2",
Expand Down Expand Up @@ -127,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->updateGitLabProject($project);
switch ($projectSelected) {
case "Drupal_project":
$this->setGitLabCiCdVariablesForPhpProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
$this->setGitLabCiCdVariablesForPhpProject($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $mysqlVersion, $phpVersion);
$this->createScheduledPipeline($project);
break;
case "Node_project":
Expand Down Expand Up @@ -218,10 +226,10 @@ private function createProjectAccessToken(array $project, string $projectAccessT
return $projectAccessToken['token'];
}

private function setGitLabCiCdVariablesForPhpProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $phpVersion): void
private function setGitLabCiCdVariablesForPhpProject(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $mysqlVersion, string $phpVersion): void
{
$this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}..");
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForPhp($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaultsForPhp($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $mysqlVersion, $phpVersion);
$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" && $variable['key'] !== "NODE_HOSTING_TYPE") {
if ($variable['key'] !== "MYSQL_VERSION" && $variable['key'] !== "PHP_VERSION" && $variable['key'] !== "NODE_VERSION" && $variable['key'] !== "NODE_HOSTING_TYPE") {
$maskedValue = $variable['masked'];
$this->assertEquals(true, $maskedValue);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ public function testCommand(mixed $mockedGitlabProjects, mixed $inputs, mixed $a
'value' => null,
'variable_type' => 'env_var',
],
[
'key' => 'MYSQL_VERSION',
'masked' => false,
'protected' => false,
'value' => null,
'variable_type' => 'env_var',
],
[
'key' => 'PHP_VERSION',
'masked' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static function providerTestCommand(): array
[self::getMockedGitLabProject(self::$gitLabProjectId)],
// Inputs.
[
0,
0,
0,
// Do you want to continue?
Expand All @@ -86,6 +87,7 @@ public static function providerTestCommand(): array
],
// Inputs.
[
0,
0,
0,
'n',
Expand All @@ -107,17 +109,19 @@ public static function providerTestCommand(): array
[],
// Inputs.
[
// Select a project type [Drupal_project]:
0,
// Select a MySQL version [5.7]:
0,
// 'Would you like to create a new Code Studio project?
'y',
// Select a project type Drupal_project.
'0',
// Select PHP version 8.1.
'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]:
// Select a PHP version [8.3]:
0,
// Would you like to link the Cloud application Sample application 1 to this repository? (yes/no) [yes]:
0,
// Would you like to create a new Code Studio project? If you select "no" you may choose from a full list of existing projects. (yes/no) [yes]:
0,
// Choose a Code Studio project to configure for the Sample application.
0,
// Do you want to continue? (yes/no) [yes]:
'y',
],
// Args.
Expand All @@ -131,8 +135,14 @@ public static function providerTestCommand(): array
[],
// Inputs.
[
// Enter Cloud Key.
self::$key,
// Enter Cloud secret,.
self::$secret,
// Select a project type Drupal_project.
'0',
// Select MySQL version 8.0.
'1',
// Select PHP version 8.2.
'1',
// Do you want to continue?
Expand All @@ -141,10 +151,7 @@ public static function providerTestCommand(): array
'y',
],
// Args.
[
'--key' => self::$key,
'--secret' => self::$secret,
],
[],
],
[
// No projects.
Expand All @@ -153,6 +160,8 @@ public static function providerTestCommand(): array
[
// Select a project type Drupal_project.
'0',
// Select MySQL version 5.7.
'0',
// Select PHP version 8.3.
'2',
// Do you want to continue?
Expand All @@ -173,6 +182,8 @@ public static function providerTestCommand(): array
[
// Select a project type Drupal_project.
'0',
// Select MySQL version 8.0.
'1',
// Select PHP version 8.4.
'3',
// Do you want to continue?
Expand Down Expand Up @@ -257,6 +268,7 @@ public static function providerTestCommand(): array
[],
// Inputs.
[
0,
0,
0,
'y',
Expand All @@ -283,6 +295,8 @@ public static function providerTestCommand(): array
self::$secret,
// Select a project type Drupal_project.
'0',
// Select MySQL version 5.7.
'0',
// Select PHP version 8.1.
'0',
// Do you want to continue?
Expand All @@ -302,6 +316,8 @@ public static function providerTestCommand(): array
self::$secret,
// Select a project type Drupal_project.
'0',
// Select MySQL version 8.0.
'1',
// Select PHP version 8.2.
'1',
// Do you want to continue?
Expand Down