Skip to content

Commit 2ef33a0

Browse files
authored
fix(cli): do not remove persistent storage by default in ExApp unregister command (#381)
Do not remove ExApp docker volume by default, deprecate old option `keep-data`, add new `rm-data` to remove ExApp data. --------- Signed-off-by: Andrey Borysenko <[email protected]>
1 parent 9a49b1c commit 2ef33a0

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2121
### Fixed
2222

2323
- TaskProcessing: fixed bug when provider wasn't removed on unregister. #370
24+
- OCC: ExApp unregister command now doesn't remove volume by default. #381
2425

2526
### Removed
2627

docs/ManagingExternalApplications.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Options
4545
Unregister
4646
----------
4747

48-
Command: ``app_api:app:unregister [--keep-data] [--force] [--silent] [--] <appid>``
48+
Command: ``app_api:app:unregister [--rm-data] [--force] [--silent] [--] <appid>``
4949

5050
To remove an ExApp you can use the unregister command.
5151
There are additional options to keep the ExApp persistent storage (data volume).
@@ -58,7 +58,7 @@ Arguments
5858
Options
5959
*******
6060

61-
* ``--keep-data`` *[optional]* - keep ExApp persistent storage (data volume)
61+
* ``--rm-data`` *[optional]* - remove ExApp persistent storage (data volume)
6262
* ``--force`` *[optional]* - continue removal even if some error occurs.
6363
* ``--silent`` *[optional]* - print a minimum of information, display only some errors, if any.
6464

lib/Command/ExApp/Unregister.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,20 @@ protected function configure(): void {
4242
null,
4343
InputOption::VALUE_NONE,
4444
'Continue removal even if errors.');
45-
$this->addOption('keep-data', null, InputOption::VALUE_NONE, 'Keep ExApp data (volume)');
45+
$this->addOption('keep-data', null, InputOption::VALUE_NONE, 'Keep ExApp data (volume) [deprecated, data is kept by default].');
46+
$this->addOption('rm-data', null, InputOption::VALUE_NONE, 'Remove ExApp data (persistent storage volume).');
4647

4748
$this->addUsage('test_app');
4849
$this->addUsage('test_app --silent');
49-
$this->addUsage('test_app --keep-data');
50-
$this->addUsage('test_app --silent --force --keep-data');
50+
$this->addUsage('test_app --rm-data');
51+
$this->addUsage('test_app --silent --force --rm-data');
5152
}
5253

5354
protected function execute(InputInterface $input, OutputInterface $output): int {
5455
$appId = $input->getArgument('appid');
5556
$silent = $input->getOption('silent');
5657
$force = $input->getOption('force');
57-
$keep_data = $input->getOption('keep-data');
58+
$rmData = $input->getOption('rm-data');
5859

5960
$exApp = $this->exAppService->getExApp($appId);
6061
if ($exApp === null) {
@@ -104,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
104105
} elseif (!$silent) {
105106
$output->writeln(sprintf('ExApp %s container successfully removed', $appId));
106107
}
107-
if (!$keep_data) {
108+
if ($rmData) {
108109
$volumeName = $this->dockerActions->buildExAppVolumeName($appId);
109110
$removeVolumeResult = $this->dockerActions->removeVolume(
110111
$this->dockerActions->buildDockerUrl($daemonConfig), $volumeName

tests/test_occ_commands_docker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def deploy_register():
6565
r = run("php occ --no-warnings app_api:app:unregister skeleton".split(), stdout=PIPE)
6666
assert r.returncode
6767
assert r.stdout.decode("UTF-8"), "Output should be non empty"
68-
# testing if "--keep-data" works.
68+
# testing if volume is kept by default
6969
deploy_register()
70-
r = run("php occ --no-warnings app_api:app:unregister skeleton --keep-data".split(), stdout=PIPE, check=True)
70+
r = run("php occ --no-warnings app_api:app:unregister skeleton".split(), stdout=PIPE, check=True)
7171
assert r.stdout.decode("UTF-8"), "Output should be non empty"
7272
run("docker volume inspect nc_app_skeleton_data".split(), check=True)
73-
# test if volume will be removed without "--keep-data"
73+
# test if volume will be removed with "--rm-data"
7474
deploy_register()
75-
run("php occ --no-warnings app_api:app:unregister skeleton".split(), check=True)
75+
run("php occ --no-warnings app_api:app:unregister skeleton --rm-data".split(), check=True)
7676
r = run("docker volume inspect nc_app_skeleton_data".split())
7777
assert r.returncode
7878
# test "--force" option

0 commit comments

Comments
 (0)