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

rhsm_release: Fix the issue that rhsm_release module considers 8, 7Client and 7Workstation as invalid releases (#2571)

* rhsm_release: Fix the issue that rhsm_release module considers 8, 7Client and 7Workstation as invalid releases.

* Fix the unit test error: The new release_matcher could pass a wider range of patterns but that would not cause extra issue to the whole module.

* Submit the changelog fragment.

* Update changelogs/fragments/2571-rhsm_release-fix-release_matcher.yaml

Co-authored-by: Amin Vakil <info@aminvakil.com>

Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
Tong He 2021-05-25 03:59:52 +08:00 committed by GitHub
parent cc293f90a2
commit 593d622438
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- rhsm_release - fix the issue that module considers 8, 7Client and 7Workstation as invalid releases (https://github.com/ansible-collections/community.general/pull/2571).

View file

@ -56,9 +56,9 @@ from ansible.module_utils.basic import AnsibleModule
import re
# Matches release-like values such as 7.2, 6.10, 10Server,
# but rejects unlikely values, like 100Server, 100.0, 1.100, etc.
release_matcher = re.compile(r'\b\d{1,2}(?:\.\d{1,2}|Server)\b')
# Matches release-like values such as 7.2, 5.10, 6Server, 8
# but rejects unlikely values, like 100Server, 1.100, 7server etc.
release_matcher = re.compile(r'\b\d{1,2}(?:\.\d{1,2}|Server|Client|Workstation|)\b')
def _sm_release(module, *args):

View file

@ -125,13 +125,12 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
def test_release_matcher(self):
# throw a few values at the release matcher -- only sane_values should match
sane_values = ['1Server', '10Server', '1.10', '10.0']
sane_values = ['1Server', '1Client', '10Server', '1.10', '10.0', '9']
insane_values = [
'6server', # lowercase 's'
'100Server', # excessively long 'x' component
'100.0', # excessively long 'x' component
'6.100', # excessively long 'y' component
'100.100', # excessively long 'x' and 'y' components
'+.-', # illegal characters
]
matches = self.module.release_matcher.findall(' '.join(sane_values + insane_values))