From ab998519cdebeea337e5b755132efd5efa0876db Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 6 Sep 2024 18:58:57 +0300 Subject: [PATCH 1/5] fix: do not remove data volume by default, add rm-data flag Signed-off-by: Andrey Borysenko --- lib/Command/ExApp/Unregister.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Command/ExApp/Unregister.php b/lib/Command/ExApp/Unregister.php index d4841f33..a46eaa89 100644 --- a/lib/Command/ExApp/Unregister.php +++ b/lib/Command/ExApp/Unregister.php @@ -42,19 +42,20 @@ protected function configure(): void { null, InputOption::VALUE_NONE, 'Continue removal even if errors.'); - $this->addOption('keep-data', null, InputOption::VALUE_NONE, 'Keep ExApp data (volume)'); + $this->addOption('keep-data', null, InputOption::VALUE_NONE, 'Keep ExApp data (volume) [deprecated, data always kept].'); + $this->addOption('rm-data', null, InputOption::VALUE_NONE, 'Remove ExApp data (persistent storage volume).'); $this->addUsage('test_app'); $this->addUsage('test_app --silent'); - $this->addUsage('test_app --keep-data'); - $this->addUsage('test_app --silent --force --keep-data'); + $this->addUsage('test_app --rm-data'); + $this->addUsage('test_app --silent --force --rm-data'); } protected function execute(InputInterface $input, OutputInterface $output): int { $appId = $input->getArgument('appid'); $silent = $input->getOption('silent'); $force = $input->getOption('force'); - $keep_data = $input->getOption('keep-data'); + $rmData = $input->getOption('rm-data'); $exApp = $this->exAppService->getExApp($appId); if ($exApp === null) { @@ -104,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } elseif (!$silent) { $output->writeln(sprintf('ExApp %s container successfully removed', $appId)); } - if (!$keep_data) { + if ($rmData) { $volumeName = $this->dockerActions->buildExAppVolumeName($appId); $removeVolumeResult = $this->dockerActions->removeVolume( $this->dockerActions->buildDockerUrl($daemonConfig), $volumeName From 13a2720baa09ce0e78264592589d2f27b1454843 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 6 Sep 2024 19:01:13 +0300 Subject: [PATCH 2/5] chore(docs): update unregister command options Signed-off-by: Andrey Borysenko --- docs/ManagingExternalApplications.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ManagingExternalApplications.rst b/docs/ManagingExternalApplications.rst index f46a89a8..3f11f524 100644 --- a/docs/ManagingExternalApplications.rst +++ b/docs/ManagingExternalApplications.rst @@ -45,7 +45,7 @@ Options Unregister ---------- -Command: ``app_api:app:unregister [--keep-data] [--force] [--silent] [--] `` +Command: ``app_api:app:unregister [--rm-data] [--force] [--silent] [--] `` To remove an ExApp you can use the unregister command. There are additional options to keep the ExApp persistent storage (data volume). @@ -58,7 +58,7 @@ Arguments Options ******* - * ``--keep-data`` *[optional]* - keep ExApp persistent storage (data volume) + * ``--rm-data`` *[optional]* - remove ExApp persistent storage (data volume) * ``--force`` *[optional]* - continue removal even if some error occurs. * ``--silent`` *[optional]* - print a minimum of information, display only some errors, if any. From db4c1e29626d4a7c7471a7c522518f164eeccb39 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 6 Sep 2024 19:04:36 +0300 Subject: [PATCH 3/5] chore: correct words Signed-off-by: Andrey Borysenko --- lib/Command/ExApp/Unregister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Command/ExApp/Unregister.php b/lib/Command/ExApp/Unregister.php index a46eaa89..cc854ff7 100644 --- a/lib/Command/ExApp/Unregister.php +++ b/lib/Command/ExApp/Unregister.php @@ -42,7 +42,7 @@ protected function configure(): void { null, InputOption::VALUE_NONE, 'Continue removal even if errors.'); - $this->addOption('keep-data', null, InputOption::VALUE_NONE, 'Keep ExApp data (volume) [deprecated, data always kept].'); + $this->addOption('keep-data', null, InputOption::VALUE_NONE, 'Keep ExApp data (volume) [deprecated, data is kept by default].'); $this->addOption('rm-data', null, InputOption::VALUE_NONE, 'Remove ExApp data (persistent storage volume).'); $this->addUsage('test_app'); From 261db7bf1b22726dbc3780f225d774585a7ac91a Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 6 Sep 2024 19:05:24 +0300 Subject: [PATCH 4/5] chore: update changelog Signed-off-by: Andrey Borysenko --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0af74b85..ee4b0dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - TaskProcessing: fixed bug when provider wasn't removed on unregister. #370 +- OCC: ExApp unregister command now doesn't remove volume by default. #381 ### Removed From 80863c28d4e6dcc49db4b8447c8458c16b9b5392 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 6 Sep 2024 19:28:49 +0300 Subject: [PATCH 5/5] chore: update tests Signed-off-by: Andrey Borysenko --- tests/test_occ_commands_docker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_occ_commands_docker.py b/tests/test_occ_commands_docker.py index e4492a89..eeb41b8f 100644 --- a/tests/test_occ_commands_docker.py +++ b/tests/test_occ_commands_docker.py @@ -65,14 +65,14 @@ def deploy_register(): r = run("php occ --no-warnings app_api:app:unregister skeleton".split(), stdout=PIPE) assert r.returncode assert r.stdout.decode("UTF-8"), "Output should be non empty" - # testing if "--keep-data" works. + # testing if volume is kept by default deploy_register() - r = run("php occ --no-warnings app_api:app:unregister skeleton --keep-data".split(), stdout=PIPE, check=True) + r = run("php occ --no-warnings app_api:app:unregister skeleton".split(), stdout=PIPE, check=True) assert r.stdout.decode("UTF-8"), "Output should be non empty" run("docker volume inspect nc_app_skeleton_data".split(), check=True) - # test if volume will be removed without "--keep-data" + # test if volume will be removed with "--rm-data" deploy_register() - run("php occ --no-warnings app_api:app:unregister skeleton".split(), check=True) + run("php occ --no-warnings app_api:app:unregister skeleton --rm-data".split(), check=True) r = run("docker volume inspect nc_app_skeleton_data".split()) assert r.returncode # test "--force" option