Skip to content

Commit

Permalink
added prompt for php version
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-bansal96 committed Sep 20, 2023
1 parent 4affeb3 commit 860403d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/Command/CodeStudio/CodeStudioCiCdVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function getList(): array {
/**
* @return array<mixed>
*/
public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL): array {
public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, int $phpVersion): array {
return [
[
'key' => 'ACQUIA_APPLICATION_UUID',
Expand Down Expand Up @@ -53,6 +53,13 @@ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string
'value' => $projectAccessToken,
'variable_type' => 'env_var',
],
[
'key' => 'PHP_VERSION',
'masked' => FALSE,
'protected' => FALSE,
'value' => $phpVersion,
'variable_type' => 'env_var',
],
];
}

Expand Down
15 changes: 12 additions & 3 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ 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());

$phpVersions = [
'PHP_version_8.1' => 8.1,
'PHP_version_8.2' => 8.2,
];
$project = $this->io->choice('Select a PHP version', array_values($phpVersions), $phpVersions['PHP_version_8.1']);
$project = array_search($project, $phpVersions, TRUE);
$phpVersion = $phpVersions[$project];

$appUuid = $this->determineCloudApplication();

// Get Cloud account.
Expand Down Expand Up @@ -92,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$projectAccessTokenName = 'acquia-codestudio';
$projectAccessToken = $this->createProjectAccessToken($project, $projectAccessTokenName);
$this->updateGitLabProject($project);
$this->setGitLabCiCdVariables($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken);
$this->setGitLabCiCdVariables($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
$this->createScheduledPipeline($project);

$this->io->success([
Expand Down Expand Up @@ -161,9 +170,9 @@ private function createProjectAccessToken(array $project, string $projectAccessT
return $projectAccessToken['token'];
}

private function setGitLabCiCdVariables(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken): void {
private function setGitLabCiCdVariables(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, int $phpVersion): void {
$this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}..");
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaults($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken);
$gitlabCicdVariables = CodeStudioCiCdVariables::getDefaults($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion);
$gitlabCicdExistingVariables = $this->gitLabClient->projects()
->variables($project['id']);
$gitlabCicdExistingVariablesKeyed = [];
Expand Down

0 comments on commit 860403d

Please sign in to comment.