generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use local helper instead of community.general.version_sort.
- Loading branch information
1 parent
5fc7286
commit a1c6ec9
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2022, Felix Fontein <[email protected]> | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
|
||
from ansible.module_utils.six import raise_from | ||
|
||
try: | ||
from ansible.module_utils.compat.version import LooseVersion | ||
except ImportError: | ||
try: | ||
from distutils.version import LooseVersion | ||
except ImportError as exc: | ||
msg = ( | ||
'To use this plugin or module with ansible-core 2.11, ansible-base 2.10,' | ||
' or Ansible 2.9, you need to use Python < 3.12 with distutils.version present' | ||
) | ||
raise_from(ImportError(msg), exc) | ||
|
||
|
||
def pick_latest_version(version_list): | ||
'''Pick latest version from a list of versions.''' | ||
return sorted(version_list, key=LooseVersion, reverse=True)[0] | ||
|
||
|
||
class FilterModule(object): | ||
'''Helper filters.''' | ||
def filters(self): | ||
return { | ||
'_community_sops_install_pick_latest_version': pick_latest_version, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters