Skip to content

Commit

Permalink
Fix inactive environment handling in ssh command
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 18, 2024
1 parent e525aca commit b3ba7dd
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Command/Environment/EnvironmentSshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,22 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$selection = $this->selector->getSelection($input, new SelectorConfig(chooseEnvFilter: SelectorConfig::filterEnvsMaybeActive()));
$environment = $selection->getEnvironment();
try {
$selection = $this->selector->getSelection($input, new SelectorConfig(chooseEnvFilter: SelectorConfig::filterEnvsMaybeActive()));
$environment = $selection->getEnvironment();

if ($input->getOption('all')) {
$output->writeln(array_values($environment->getSshUrls()));
if ($input->getOption('all')) {
$output->writeln(array_values($environment->getSshUrls()));

return 0;
}
return 0;
}

$container = $selection->getRemoteContainer();
$container = $selection->getRemoteContainer();

try {
$sshUrl = $container->getSshUrl($input->getOption('instance'));
} catch (EnvironmentStateException $e) {
if ($e->getEnvironment()->id !== $environment->id) {
throw $e;
}
switch ($e->getEnvironment()->status) {
$environment = $e->getEnvironment();
switch ($environment->status) {
case 'inactive':
$this->stdErr->writeln(sprintf('The environment %s is inactive, so an SSH connection is not possible.', $this->api->getEnvironmentLabel($e->getEnvironment(), 'error')));
if (!$e->getEnvironment()->has_code) {
Expand Down

0 comments on commit b3ba7dd

Please sign in to comment.