Browse Source

Make regex for the openshift_pkg_version simpler

The regex for the openshift_pkg_version accepts as longa as it starts
with '-'.
Kenjiro Nakayama 6 years ago
parent
commit
e10267a7d1

+ 2 - 2
roles/lib_utils/action_plugins/sanity_checks.py

@@ -35,9 +35,9 @@ IMAGE_TAG_REGEX = {'origin': ORIGIN_TAG_REGEX,
                    'openshift-enterprise': ENTERPRISE_TAG_REGEX}
 
 PKG_VERSION_REGEX_ERROR = """openshift_pkg_version must be in the format
--3.#.#[-optional.release]. Examples: -3.6.0, -3.7.0-0.126.0.git.0.9351aae.el7 -3.11*
+-[optional.release]. Examples: -3.6.0, -3.7.0-0.126.0.git.0.9351aae.el7 -3.11*
 You specified openshift_pkg_version={}"""
-PKG_VERSION_REGEX = {'re': '((^-\\d+\\.\\d+\\.\\d+((-\\d+.*))?$)|(.*\\*$))',
+PKG_VERSION_REGEX = {'re': '(^-.*)',
                      'error_msg': PKG_VERSION_REGEX_ERROR}
 
 RELEASE_REGEX_ERROR = """openshift_release must be in the format

+ 1 - 1
roles/lib_utils/test/sanity_check_test.py

@@ -26,6 +26,7 @@ def test_template_var(hostvars, host, varname, result):
     ({"example.com": {"openshift_pkg_version": "-3.7.0-0.126.0.git.0.9351aae.el7"}}, "example.com", None),
     ({"example.com": {"openshift_pkg_version": "-3.9.0-2.fc28"}}, "example.com", None),
     ({"example.com": {"openshift_pkg_version": "-3.11*"}}, "example.com", None),
+    ({"example.com": {"openshift_pkg_version": "-3"}}, "example.com", None),
 ])
 def test_valid_check_pkg_version_format(hostvars, host, result):
     task = FakeTask('sanity_checks', {'checks': []})
@@ -36,7 +37,6 @@ def test_valid_check_pkg_version_format(hostvars, host, result):
 
 @pytest.mark.parametrize('hostvars, host, result', [
     ({"example.com": {"openshift_pkg_version": "3.11.0"}}, "example.com", None),
-    ({"example.com": {"openshift_pkg_version": "-3.11"}}, "example.com", None),
     ({"example.com": {"openshift_pkg_version": "v3.11.0"}}, "example.com", None),
 ])
 def test_invalid_check_pkg_version_format(hostvars, host, result):