Skip to content

Commit

Permalink
CLI-1217: push:artifact should infer app id from env id
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Nov 16, 2023
1 parent 79d271c commit bdf9f5f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,20 @@ protected function determineCloudApplication(bool $promptLinkApp = FALSE): ?stri
return $applicationUuid;
}

protected function doDetermineCloudApplication(): mixed {
protected function doDetermineCloudApplication(): ?string {
$acquiaCloudClient = $this->cloudApiClientService->getClient();

if ($this->input->hasArgument('applicationUuid') && $this->input->getArgument('applicationUuid')) {
$cloudApplicationUuid = $this->input->getArgument('applicationUuid');
return self::validateUuid($cloudApplicationUuid);
}

if ($this->input->hasArgument('environmentId') && $this->input->getArgument('environmentId')) {
$environmentId = $this->input->getArgument('environmentId');
$environment = $this->getCloudEnvironment($environmentId);
return $environment->application->uuid;
}

// Try local project info.
if ($applicationUuid = $this->getCloudUuidFromDatastore()) {
$this->logger->debug("Using Cloud application UUID: $applicationUuid from {$this->datastoreAcli->filepath}");
Expand Down Expand Up @@ -745,14 +751,14 @@ private function saveCloudUuidToDatastore(ApplicationResponse $application): boo
return TRUE;
}

protected function getCloudUuidFromDatastore(): mixed {
protected function getCloudUuidFromDatastore(): ?string {
return $this->datastoreAcli->get('cloud_app_uuid');
}

private function promptLinkApplication(
?ApplicationResponse $cloudApplication
ApplicationResponse $cloudApplication
): bool {
$answer = $this->io->confirm("Would you like to link the Cloud application <bg=cyan;options=bold>{$cloudApplication->name}</> to this repository?");
$answer = $this->io->confirm("Would you like to link the Cloud application <bg=cyan;options=bold>$cloudApplication->name</> to this repository?");
if ($answer) {
return $this->saveCloudUuidToDatastore($cloudApplication);
}
Expand All @@ -778,10 +784,8 @@ public static function isAcquiaCloudIde(): bool {
* Get the Cloud Application UUID from a Cloud IDE's environmental variable.
*
* This command assumes it is being run inside a Cloud IDE.
*
* @return array<string>|false|string
*/
protected static function getThisCloudIdeCloudAppUuid(): bool|array|string {
protected static function getThisCloudIdeCloudAppUuid(): false|string {
return getenv('ACQUIA_APPLICATION_UUID');
}

Expand Down

0 comments on commit bdf9f5f

Please sign in to comment.