Skip to content

Commit

Permalink
add separate option for ExApp removal
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey18106 committed Aug 17, 2023
1 parent d6e039d commit c2963e7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/Command/ExApp/Unregister.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ protected function configure() {
$this->addArgument('appid', InputArgument::REQUIRED);

$this->addOption('silent', null, InputOption::VALUE_NONE, 'Unregister only from Nextcloud. Do not send request to external app.');
$this->addOption('rm', null, InputOption::VALUE_NONE, 'Remove ExApp container');
$this->addOption('rm-container', null, InputOption::VALUE_NONE, 'Remove ExApp container');
$this->addOption('rm-data', null, InputOption::VALUE_NONE, 'Remove ExApp data (volume)');

$this->addUsage('test_app');
$this->addUsage('test_app --silent');
Expand Down Expand Up @@ -71,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 1;
}

$rmContainer = $input->getOption('rm');
$rmContainer = $input->getOption('rm-container');
if ($rmContainer) {
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($exApp->getDaemonConfigName());
if ($daemonConfig === null) {
Expand All @@ -84,9 +85,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (isset($stopResult['error']) || isset($removeResult['error'])) {
$output->writeln(sprintf('Failed to remove ExApp %s container', $appId));
} else {
$removeVolumeResult = $this->dockerActions->removeVolume($this->dockerActions->buildDockerUrl($daemonConfig), $appId . '_data');
if (isset($removeVolumeResult['error'])) {
$output->writeln(sprintf('Failed to remove ExApp %s volume %s', $appId, $appId . '_data'));
$rmData = $input->getOption('rm-data');
if ($rmData) {
$removeVolumeResult = $this->dockerActions->removeVolume($this->dockerActions->buildDockerUrl($daemonConfig), $appId . '_data');
if (isset($removeVolumeResult['error'])) {
$output->writeln(sprintf('Failed to remove ExApp %s volume %s', $appId, $appId . '_data'));
}
}
$output->writeln(sprintf('ExApp %s container successfully removed', $appId));
}
Expand Down

0 comments on commit c2963e7

Please sign in to comment.