mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-04 05:04:22 -07:00
Reject apk with update cache for empty package names
This commit is contained in:
parent
8a66a9edb0
commit
7570874dc3
2 changed files with 19 additions and 6 deletions
|
@ -351,6 +351,9 @@ def main():
|
|||
|
||||
p = module.params
|
||||
|
||||
if all(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']:
|
||||
APK_PATH = "%s --no-cache" % (APK_PATH, )
|
||||
|
||||
|
@ -371,9 +374,6 @@ def main():
|
|||
if p['upgrade']:
|
||||
upgrade_packages(module, p['available'])
|
||||
|
||||
if all(not name.strip() for name in p['name']):
|
||||
module.fail_json(msg="Package name(s) cannot be empty or whitespace-only")
|
||||
|
||||
if p['state'] in ['present', 'latest']:
|
||||
install_packages(module, p['name'], p['state'], p['world'])
|
||||
elif p['state'] == 'absent':
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_empty is failed
|
||||
- "'Package name(s) cannot be empty' in result_empty.msg"
|
||||
- "'Package name(s) cannot be empty or whitespace-only' == result_empty.msg"
|
||||
|
||||
- name: Install package name with only spaces
|
||||
community.general.apk:
|
||||
|
@ -181,7 +181,7 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_spaces is failed
|
||||
- "'Package name(s) cannot be empty' in result_spaces.msg"
|
||||
- "'Package name(s) cannot be empty or whitespace-only' == result_spaces.msg"
|
||||
|
||||
- name: Accept list with valid and empty string
|
||||
community.general.apk:
|
||||
|
@ -204,4 +204,17 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_multiple_empty is failed
|
||||
- "'Package name(s) cannot be empty' in result_multiple_empty.msg"
|
||||
- "'Package name(s) cannot be empty or whitespace-only' == result_multiple_empty.msg"
|
||||
|
||||
- name: Reject empty package name with update_cache parameter
|
||||
community.general.apk:
|
||||
name: ""
|
||||
update_cache: true
|
||||
register: result_empty_package_with_update_cache
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert failure due to all package names being empty or whitespace
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result_empty_package_with_update_cache is failed
|
||||
- "'Package name(s) cannot be empty or whitespace-only' == result_empty_package_with_update_cache.msg"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue