1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

snap: fix regex to support option values with whitespaces (#5475)

* snap: fix regex to support option values with whitespaces

* add changelog fragment
This commit is contained in:
Alexei Znamensky 2022-11-06 23:41:11 +13:00 committed by GitHub
parent fb90b5cbe8
commit 8fb2228125
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- snap - allow values in the ``options`` parameter to contain whitespaces (https://github.com/ansible-collections/community.general/pull/5475).

View file

@ -170,7 +170,7 @@ def _state_map(value):
class Snap(CmdStateModuleHelper): class Snap(CmdStateModuleHelper):
__disable_re = re.compile(r'(?:\S+\s+){5}(?P<notes>\S+)') __disable_re = re.compile(r'(?:\S+\s+){5}(?P<notes>\S+)')
__set_param_re = re.compile(r'(?P<snap_prefix>\S+:)?(?P<key>\S+)=(?P<value>\S+)') __set_param_re = re.compile(r'(?P<snap_prefix>\S+:)?(?P<key>\S+)\s*=\s*(?P<value>.+)')
module = dict( module = dict(
argument_spec={ argument_spec={
'name': dict(type='list', elements='str', required=True), 'name': dict(type='list', elements='str', required=True),
@ -342,7 +342,7 @@ class Snap(CmdStateModuleHelper):
if selected_snap_name is None or (snap_name is not None and snap_name == selected_snap_name): if selected_snap_name is None or (snap_name is not None and snap_name == selected_snap_name):
key = match.group("key") key = match.group("key")
value = match.group("value") value = match.group("value").strip()
if key not in option_map or key in option_map and option_map[key] != value: if key not in option_map or key in option_map and option_map[key] != value:
option_without_prefix = key + "=" + value option_without_prefix = key + "=" + value

View file

@ -8,7 +8,9 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
- block: - name: Has-snap block
when: has_snap
block:
- name: Make sure package is not installed (hello-world) - name: Make sure package is not installed (hello-world)
community.general.snap: community.general.snap:
name: hello-world name: hello-world
@ -189,5 +191,3 @@
- "'uhttpd:document-root-dir=/tmp' in install_with_option_changed.options_changed" - "'uhttpd:document-root-dir=/tmp' in install_with_option_changed.options_changed"
- "'uhttpd:listening-port=8080' not in install_with_option_changed.options_changed" - "'uhttpd:listening-port=8080' not in install_with_option_changed.options_changed"
- remove is changed - remove is changed
when: has_snap