diff --git a/src/Command/Remote/SshCommand.php b/src/Command/Remote/SshCommand.php index c709517e9..a98bdd17a 100644 --- a/src/Command/Remote/SshCommand.php +++ b/src/Command/Remote/SshCommand.php @@ -2,6 +2,7 @@ namespace Acquia\Cli\Command\Remote; +use Acquia\Cli\Exception\AcquiaCliException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -27,6 +28,9 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int $alias = $this->normalizeAlias($alias); $alias = self::validateEnvironmentAlias($alias); $environment = $this->getEnvironmentFromAliasArg($alias); + if (!isset($environment->sshUrl)) { + throw new AcquiaCliException('Cannot determine environment SSH URL. Check that you have SSH permissions on this environment.'); + } $sshCommand = [ 'cd /var/www/html/' . $alias, ]; diff --git a/src/Helpers/SshHelper.php b/src/Helpers/SshHelper.php index 231f84ac2..04fcd14d6 100644 --- a/src/Helpers/SshHelper.php +++ b/src/Helpers/SshHelper.php @@ -28,8 +28,11 @@ public function __construct( /** * Execute the command in a remote environment. * + * @param \AcquiaCloudApi\Response\EnvironmentResponse|string $target * @param array $commandArgs + * @param bool $printOutput * @param int|null $timeout + * @return \Symfony\Component\Process\Process */ public function executeCommand(EnvironmentResponse|string $target, array $commandArgs, bool $printOutput = TRUE, int $timeout = NULL): Process { $commandSummary = $this->getCommandSummary($commandArgs); @@ -66,6 +69,7 @@ private function sendCommand($url, $command, $printOutput, $timeout = NULL): Pro * Return the first item of the $commandArgs that is not an option. * * @param array $commandArgs + * @return string */ private function firstArguments(array $commandArgs): string { $result = ''; @@ -80,9 +84,6 @@ private function firstArguments(array $commandArgs): string { return $result; } - /** - * @return \Closure - */ private function getOutputCallback(): callable { if ($this->localMachineHelper->useTty() === FALSE) { $output = $this->output; @@ -101,15 +102,12 @@ private function getOutputCallback(): callable { * CI scripts. * * @param array $commandArgs + * @return string */ private function getCommandSummary(array $commandArgs): string { return $this->firstArguments($commandArgs); } - /** - * @param $url - * @return array SSH connection string - */ private function getConnectionArgs($url): array { return [ 'ssh', @@ -121,10 +119,6 @@ private function getConnectionArgs($url): array { ]; } - /** - * @param $command - * @return array - */ private function getSshCommand(string $url, $command): array { return array_merge($this->getConnectionArgs($url), $command); }