Skip to content

Commit 2a176ae

Browse files
committed
Do not require SSH permission to list mounts
1 parent 7273878 commit 2a176ae

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/Command/Mount/MountListCommand.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,27 @@ protected function configure()
3636
*/
3737
protected function execute(InputInterface $input, OutputInterface $output)
3838
{
39-
$host = $this->selectHost($input, getenv($this->config()->get('service.env_prefix') . 'APPLICATION'));
4039
/** @var \Platformsh\Cli\Service\Mount $mountService */
4140
$mountService = $this->getService('mount');
42-
if ($host instanceof LocalHost) {
43-
/** @var \Platformsh\Cli\Service\RemoteEnvVars $envVars */
44-
$envVars = $this->getService('remote_env_vars');
45-
$config = (new AppConfig($envVars->getArrayEnvVar('APPLICATION', $host)));
41+
if (($applicationEnv = getenv($this->config()->get('service.env_prefix') . 'APPLICATION'))
42+
&& !LocalHost::conflictsWithCommandLineOptions($input, $this->config()->get('service.env_prefix'))) {
43+
$this->debug('Selected host: localhost');
44+
$config = json_decode(base64_decode($applicationEnv), true) ?: [];
4645
$mounts = $mountService->mountsFromConfig($config);
46+
$appName = $config['name'];
4747
} else {
48+
$this->validateInput($input);
4849
$container = $this->selectRemoteContainer($input);
4950
$mounts = $mountService->mountsFromConfig($container->getConfig());
51+
$appName = $container->getName();
5052
}
5153

54+
$appType = strpos($appName, '--') !== false ? 'worker' : 'app';
55+
5256
if (empty($mounts)) {
53-
$this->stdErr->writeln(sprintf('No mounts found on host: <info>%s</info>', $host->getLabel()));
57+
$this->stdErr->writeln(sprintf('No mounts found on %s: <info>%s</info>', $appType, $appName));
5458

55-
return 1;
59+
return 0;
5660
}
5761

5862
if ($input->getOption('paths')) {
@@ -70,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7074

7175
/** @var \Platformsh\Cli\Service\Table $table */
7276
$table = $this->getService('table');
73-
$this->stdErr->writeln(sprintf('Mounts on <info>%s</info>:', $host->getLabel()));
77+
$this->stdErr->writeln(sprintf('Mounts on %s: <info>%s</info>', $appType, $appName));
7478
$table->render($rows, $this->tableHeader);
7579

7680
return 0;

0 commit comments

Comments
 (0)