mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Use regexp to check if the value matches expected form
regexp should match values like:
- 1B
- 10MB
- 10mb
* Added changelog entry
* Update changelogs/fragments/1079-redis-use-regexp-to-check-if-the-value-matches-expected-form.yaml
Co-authored-by: Amin Vakil <info@aminvakil.com>
Co-authored-by: Amin Vakil <info@aminvakil.com>
(cherry picked from commit bcfd648855
)
Co-authored-by: Robbert Müller <mjrider@users.noreply.github.com>
This commit is contained in:
parent
705118247d
commit
788dc4bc23
2 changed files with 7 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- redis - fixes parsing of config values which should not be converted to bytes (https://github.com/ansible-collections/community.general/pull/1079).
|
|
@ -131,6 +131,7 @@ else:
|
|||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.formatters import human_to_bytes
|
||||
from ansible.module_utils._text import to_native
|
||||
import re
|
||||
|
||||
|
||||
# Redis module specific support methods.
|
||||
|
@ -277,7 +278,10 @@ def main():
|
|||
name = module.params['name']
|
||||
|
||||
try: # try to parse the value as if it were the memory size
|
||||
if re.match(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?\s*$', module.params['value'].upper()):
|
||||
value = str(human_to_bytes(module.params['value'].upper()))
|
||||
else:
|
||||
value = module.params['value']
|
||||
except ValueError:
|
||||
value = module.params['value']
|
||||
|
||||
|
|
Loading…
Reference in a new issue