Skip to content

Commit

Permalink
Revert to tuple/reduce version check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Rodriguez committed Jan 23, 2023
1 parent 8a96baf commit 19d971d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/module_utils/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)

from __future__ import (absolute_import, division, print_function)
from pkg_resources import parse_version
from functools import reduce
__metaclass__ = type

import os
Expand Down Expand Up @@ -92,7 +92,8 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
config['connect_timeout'] = connect_timeout
if check_hostname is not None:
if mysql_driver.__name__ == "pymysql":
if parse_version(mysql_driver.__version__) >= parse_version("0.7.11"):
version_tuple = (n for n in mysql_driver.__version__.split('.') if n != 'None')
if reduce(lambda x, y: int(x) * 100 + int(y), version_tuple) >= 711:
config['ssl']['check_hostname'] = check_hostname
else:
module.fail_json(msg='To use check_hostname, pymysql >= 0.7.11 is required on the target host')
Expand Down

0 comments on commit 19d971d

Please sign in to comment.