Skip to content

Commit 885402b

Browse files
authored
Merge pull request #791 from isaaclee12/feat/785/add-deploy-config-info
feat(daemon): add --show-deploy-config flag to daemon:list command
2 parents 004e328 + 24a98a6 commit 885402b

File tree

2 files changed

+46
-22
lines changed

2 files changed

+46
-22
lines changed

lib/Command/Daemon/ListDaemons.php

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99

1010
namespace OCA\AppAPI\Command\Daemon;
1111

12+
use OC\Core\Command\Base;
1213
use OCA\AppAPI\AppInfo\Application;
1314
use OCA\AppAPI\Service\DaemonConfigService;
14-
1515
use OCP\IAppConfig;
16-
use Symfony\Component\Console\Command\Command;
1716
use Symfony\Component\Console\Helper\Table;
1817
use Symfony\Component\Console\Input\InputInterface;
1918
use Symfony\Component\Console\Output\OutputInterface;
2019

21-
class ListDaemons extends Command {
20+
class ListDaemons extends Base {
2221

2322
public function __construct(
2423
private readonly DaemonConfigService $daemonConfigService,
@@ -28,6 +27,7 @@ public function __construct(
2827
}
2928

3029
protected function configure(): void {
30+
parent::configure();
3131
$this->setName('app_api:daemon:list');
3232
$this->setDescription('List registered daemons');
3333
}
@@ -41,27 +41,50 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4141

4242
$defaultDaemonName = $this->appConfig->getValueString(Application::APP_ID, 'default_daemon_config', lazy: true);
4343

44-
$output->writeln('Registered ExApp daemon configs:');
45-
$table = new Table($output);
46-
$table->setHeaders(['Def', 'Name', 'Display name', 'Deploy ID', 'Protocol', 'Host', 'NC Url', 'Is HaRP', 'HaRP FRP Address', 'HaRP Docker Socket Port']);
47-
$rows = [];
44+
if (in_array($input->getOption('output'), [self::OUTPUT_FORMAT_JSON, self::OUTPUT_FORMAT_JSON_PRETTY], true)) {
45+
$allDaemonInfo = [];
46+
foreach ($daemonConfigs as $daemon) {
47+
$deployConfig = $daemon->getDeployConfig();
4848

49-
foreach ($daemonConfigs as $daemon) {
50-
$rows[] = [
51-
$daemon->getName() === $defaultDaemonName ? '*' : '',
52-
$daemon->getName(), $daemon->getDisplayName(),
53-
$daemon->getAcceptsDeployId(),
54-
$daemon->getProtocol(),
55-
$daemon->getHost(),
56-
$daemon->getDeployConfig()['nextcloud_url'],
57-
isset($daemon->getDeployConfig()['harp']) ? 'yes' : 'no',
58-
$daemon->getDeployConfig()['harp']['frp_address'] ?? '(none)',
59-
$daemon->getDeployConfig()['harp']['docker_socket_port'] ?? '(none)',
60-
];
61-
}
49+
if (isset($deployConfig['haproxy_password'])) {
50+
$deployConfig['haproxy_password'] = '***';
51+
}
52+
53+
$allDaemonInfo[] = [
54+
'name' => $daemon->getName(),
55+
'display_name' => $daemon->getDisplayName(),
56+
'deploy_id' => $daemon->getAcceptsDeployId(),
57+
'protocol' => $daemon->getProtocol(),
58+
'host' => $daemon->getHost(),
59+
'deploy_config' => $deployConfig,
60+
];
61+
}
62+
$this->writeArrayInOutputFormat($input, $output, $allDaemonInfo);
63+
} else {
64+
$table = new Table($output);
65+
$table->setHeaders(['Def', 'Name', 'Display name', 'Deploy ID', 'Protocol', 'Host', 'NC Url', 'Is HaRP', 'HaRP FRP Address', 'HaRP Docker Socket Port']);
6266

63-
$table->setRows($rows);
64-
$table->render();
67+
$rows = [];
68+
foreach ($daemonConfigs as $daemon) {
69+
$deployConfig = $daemon->getDeployConfig();
70+
$rows[] = [
71+
$daemon->getName() === $defaultDaemonName ? '*' : '',
72+
$daemon->getName(),
73+
$daemon->getDisplayName(),
74+
$daemon->getAcceptsDeployId(),
75+
$daemon->getProtocol(),
76+
$daemon->getHost(),
77+
$deployConfig['nextcloud_url'],
78+
isset($deployConfig['harp']) ? 'yes' : 'no',
79+
$deployConfig['harp']['frp_address'] ?? '(none)',
80+
$deployConfig['harp']['docker_socket_port'] ?? '(none)',
81+
];
82+
}
83+
84+
$table->setRows($rows);
85+
$output->writeln('Registered ExApp daemon configs:');
86+
$table->render();
87+
}
6588

6689
return 0;
6790
}

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<referencedClass name="OCA\DAV\Events\SabrePluginAuthInitEvent" />
3636
<referencedClass name="GuzzleHttp\Client" />
3737
<referencedClass name="GuzzleHttp\Exception\GuzzleException" />
38+
<referencedClass name="OC\Core\Command\Base" />
3839
<referencedClass name="OC\Security\CSP\ContentSecurityPolicyNonceManager" />
3940
<referencedClass name="Symfony\Component\Console\Command\Command" />
4041
</errorLevel>

0 commit comments

Comments
 (0)