mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
python_requirements_info - fail when version operator used without version (#3785)
* python_requirements_info - fail when version operator used without version * added changelog fragment * simplified way of achieving the same result
This commit is contained in:
parent
1cc6938ae3
commit
59c1859fb3
3 changed files with 16 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- python_requirements_info - fails if version operator used without version (https://github.com/ansible-collections/community.general/pull/3785).
|
|
@ -121,7 +121,7 @@ def main():
|
||||||
python_version=sys.version,
|
python_version=sys.version,
|
||||||
python_system_path=sys.path,
|
python_system_path=sys.path,
|
||||||
)
|
)
|
||||||
pkg_dep_re = re.compile(r'(^[a-zA-Z][a-zA-Z0-9_-]+)(==|[><]=?)?([0-9.]+)?$')
|
pkg_dep_re = re.compile(r'(^[a-zA-Z][a-zA-Z0-9_-]+)(?:(==|[><]=?)([0-9.]+))?$')
|
||||||
|
|
||||||
results = dict(
|
results = dict(
|
||||||
not_found=[],
|
not_found=[],
|
||||||
|
@ -131,7 +131,7 @@ def main():
|
||||||
|
|
||||||
for dep in (module.params.get('dependencies') or []):
|
for dep in (module.params.get('dependencies') or []):
|
||||||
match = pkg_dep_re.match(dep)
|
match = pkg_dep_re.match(dep)
|
||||||
if match is None:
|
if not match:
|
||||||
module.fail_json(msg="Failed to parse version requirement '{0}'. Must be formatted like 'ansible>2.6'".format(dep))
|
module.fail_json(msg="Failed to parse version requirement '{0}'. Must be formatted like 'ansible>2.6'".format(dep))
|
||||||
pkg, op, version = match.groups()
|
pkg, op, version = match.groups()
|
||||||
if op is not None and op not in operations:
|
if op is not None and op not in operations:
|
||||||
|
|
|
@ -25,3 +25,15 @@
|
||||||
that:
|
that:
|
||||||
- "'installed' in dep_info.valid.pip"
|
- "'installed' in dep_info.valid.pip"
|
||||||
- "'notreal' in dep_info.not_found"
|
- "'notreal' in dep_info.not_found"
|
||||||
|
|
||||||
|
- name: wrong specs
|
||||||
|
python_requirements_info:
|
||||||
|
dependencies:
|
||||||
|
- ansible<
|
||||||
|
register: wrong_spec1
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: ensure wrong specs return error
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- wrong_spec1 is failed
|
||||||
|
|
Loading…
Reference in a new issue