mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 20:54:24 -07:00
apk: fix empty/whitespace-only package name check (#10532)
* Fix empty/whitespace-only package name check. * Adjust test.
This commit is contained in:
parent
ac4aca2004
commit
abfe1e6180
3 changed files with 8 additions and 5 deletions
2
changelogs/fragments/10532-apk.yml
Normal file
2
changelogs/fragments/10532-apk.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "apk - fix check for empty/whitespace-only package names (https://github.com/ansible-collections/community.general/pull/10532)."
|
|
@ -351,7 +351,7 @@ def main():
|
|||
|
||||
p = module.params
|
||||
|
||||
if all(not name.strip() for name in p['name']):
|
||||
if p['name'] and any(not name.strip() for name in p['name']):
|
||||
module.fail_json(msg="Package name(s) cannot be empty or whitespace-only")
|
||||
|
||||
if p['no_cache']:
|
||||
|
|
|
@ -183,16 +183,17 @@
|
|||
- result_spaces is failed
|
||||
- "'Package name(s) cannot be empty or whitespace-only' == result_spaces.msg"
|
||||
|
||||
- name: Accept list with valid and empty string
|
||||
- name: Do not accept list with valid and empty string
|
||||
community.general.apk:
|
||||
name: ["busybox", ""]
|
||||
register: result_valid_mixed
|
||||
register: result_invalid_mixed
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert success with mixed package list
|
||||
- name: Assert failure with mixed package list
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_valid_mixed is not failed
|
||||
- result_invalid_mixed is failed
|
||||
- "'Package name(s) cannot be empty or whitespace-only' == result_invalid_mixed.msg"
|
||||
|
||||
- name: Reject package name list with multiple empty/whitespace-only strings
|
||||
community.general.apk:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue