Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version comparison (impl 2) #337

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions plugins/module_utils/ah_api_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import time

from ansible.module_utils.basic import AnsibleModule, env_fallback
from ansible.module_utils.compat.version import LooseVersion as Version
from ansible.module_utils._text import to_bytes, to_text

from ansible.module_utils.six.moves.urllib.parse import urlparse, urlencode
Expand Down Expand Up @@ -485,9 +486,9 @@ def exit_json(self, **kwargs):
def get_server_version(self):
"""Return the automation hub/galaxy server version.

:return: the server version ("4.2.5" for example) or an empty string if
:return: the server Version("4.2.5") for example or Version("0") if
that information is not available.
:rtype: str
:rtype: Version
"""
url = self._build_url(self.galaxy_path_prefix)
try:
Expand All @@ -501,4 +502,6 @@ def get_server_version(self):
else:
fail_msg = "Unable to get server version: {code}".format(code=response["status_code"])
self.fail_json(msg=fail_msg)
return response["json"]["server_version"].replace('dev', '') if "server_version" in response["json"] else ""
return Version(
response["json"]["server_version"].replace('dev', '') if "server_version" in response["json"] else "0"
)
Loading