Skip to content

Commit 7835e39

Browse files
authored
Bugfix: adjust incorrectly passed keywords with exclude-strings argument (ansible#15721)
* Fix incorrectly passed keywords with exclude-strings arg to ansible-runner worker cleanup command Signed-off-by: Sasa Jovicic <[email protected]> * Keep the quotes for each arg and adjust test_receptor --------- Signed-off-by: Sasa Jovicic <[email protected]>
1 parent 14808cb commit 7835e39

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

awx/main/tasks/receptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def _convert_args_to_cli(vargs):
360360
args = ['cleanup']
361361
for option in ('exclude_strings', 'remove_images'):
362362
if vargs.get(option):
363-
args.append('--{}="{}"'.format(option.replace('_', '-'), ' '.join(vargs.get(option))))
363+
args.append('--{} {}'.format(option.replace('_', '-'), ' '.join(f'"{item}"' for item in vargs.get(option))))
364364
for option in ('file_pattern', 'image_prune', 'process_isolation_executable', 'grace_period'):
365365
if vargs.get(option) is True:
366366
args.append('--{}'.format(option.replace('_', '-')))

awx/main/tests/unit/utils/test_receptor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def test_file_cleanup_scenario():
55
args = _convert_args_to_cli({'exclude_strings': ['awx_423_', 'awx_582_'], 'file_pattern': '/tmp/awx_*_*'})
6-
assert ' '.join(args) == 'cleanup --exclude-strings="awx_423_ awx_582_" --file-pattern=/tmp/awx_*_*'
6+
assert ' '.join(args) == 'cleanup --exclude-strings "awx_423_" "awx_582_" --file-pattern=/tmp/awx_*_*'
77

88

99
def test_image_cleanup_scenario():
@@ -17,5 +17,6 @@ def test_image_cleanup_scenario():
1717
}
1818
)
1919
assert (
20-
' '.join(args) == 'cleanup --remove-images="quay.invalid/foo/bar:latest quay.invalid/foo/bar:devel" --image-prune --process-isolation-executable=podman'
20+
' '.join(args)
21+
== 'cleanup --remove-images "quay.invalid/foo/bar:latest" "quay.invalid/foo/bar:devel" --image-prune --process-isolation-executable=podman'
2122
)

0 commit comments

Comments
 (0)