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

[PR #8185/9307b76e backport][stable-8] fix: Ensuring interpolation is disabled for ConfigParser (#8210)

fix: Ensuring interpolation is disabled for ConfigParser (#8185)

* fix: Ensuring interpolation is disabled for ConfigParser

This PR disables interpolation of ConfigParser and adds test coverage for that.

* Adding changelog fragment

* Fixing missing extension of changelog fragment

* Adding issue link to changelog fragment

* Update changelogs/fragments/8183-from_ini_to_ini.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9307b76e74)

Co-authored-by: Steffen Scheib <37306894+sscheib@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2024-04-09 12:28:37 +02:00 committed by GitHub
parent 39dd596e67
commit 66200a5da5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 4 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- "to_ini filter plugin - disabling interpolation of ``ConfigParser`` to allow converting values with a ``%`` sign (https://github.com/ansible-collections/community.general/issues/8183, https://github.com/ansible-collections/community.general/pull/8185)."
- "from_ini filter plugin - disabling interpolation of ``ConfigParser`` to allow converting values with a ``%`` sign (https://github.com/ansible-collections/community.general/issues/8183, https://github.com/ansible-collections/community.general/pull/8185)."

View file

@ -57,7 +57,7 @@ class IniParser(ConfigParser):
''' Implements a configparser which is able to return a dict '''
def __init__(self):
super().__init__()
super().__init__(interpolation=None)
self.optionxform = str
def as_dict(self):

View file

@ -63,7 +63,7 @@ class IniParser(ConfigParser):
''' Implements a configparser which sets the correct optionxform '''
def __init__(self):
super().__init__()
super().__init__(interpolation=None)
self.optionxform = str

View file

@ -12,6 +12,9 @@
another_section:
connection: 'ssh'
interpolate_test:
interpolate_test_key: '%'
- name: 'Write INI file that reflects ini_test_dict to {{ ini_test_file }}'
ansible.builtin.copy:
dest: '{{ ini_test_file }}'
@ -22,6 +25,9 @@
[another_section]
connection = ssh
[interpolate_test]
interpolate_test_key = %
- name: 'Slurp the test file: {{ ini_test_file }}'
ansible.builtin.slurp:
src: '{{ ini_test_file }}'

View file

@ -16,6 +16,9 @@
another_section:
connection: 'ssh'
interpolate_test:
interpolate_test_key: '%'
- name: 'Write INI file manually to {{ ini_test_file }}'
ansible.builtin.copy:
dest: '{{ ini_test_file }}'
@ -26,6 +29,9 @@
[another_section]
connection = ssh
[interpolate_test]
interpolate_test_key = %
- name: 'Slurp the manually created test file: {{ ini_test_file }}'
ansible.builtin.slurp:
src: '{{ ini_test_file }}'