-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathListRegistry.php
More file actions
58 lines (46 loc) · 1.72 KB
/
Copy pathListRegistry.php
File metadata and controls
58 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\AppAPI\Command\Daemon;
use OCA\AppAPI\Service\DaemonConfigService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ListRegistry extends Command {
public function __construct(
private readonly DaemonConfigService $daemonConfigService,
) {
parent::__construct();
}
protected function configure(): void {
$this->setName('app_api:daemon:registry:list');
$this->setDescription('List the configured deploy daemon Docker registry mappings');
$this->addArgument('name', InputArgument::REQUIRED, 'Deploy daemon name');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$name = $input->getArgument('name');
if (!$name) {
$output->writeln('Daemon name is required.');
return 1;
}
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($name);
if ($daemonConfig === null) {
$output->writeln('Daemon config not found.');
return 1;
}
if (!isset($daemonConfig->getDeployConfig()['registries']) || count($daemonConfig->getDeployConfig()['registries']) === 0) {
$output->writeln(sprintf('No registries configured for daemon "%s".', $name));
return 0;
}
$registries = $daemonConfig->getDeployConfig()['registries'];
$output->writeln(sprintf('Configured registries for daemon "%s":', $name));
foreach ($registries as $registry) {
$output->writeln(sprintf(' - %s -> %s', $registry['from'], $registry['to']));
}
return 0;
}
}