-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from guidograzioli/runtimes_common_patching
Switch to middleware_automation.common for rh-sso patching
- Loading branch information
Showing
5 changed files
with
142 additions
and
15 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,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2021 Eric Lavarde <[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 | ||
|
||
DOCUMENTATION = ''' | ||
name: version_sort | ||
short_description: Sort a list according to version order instead of pure alphabetical one | ||
version_added: 2.2.0 | ||
author: Eric L. (@ericzolf) | ||
description: | ||
- Sort a list according to version order instead of pure alphabetical one. | ||
options: | ||
_input: | ||
description: A list of strings to sort. | ||
type: list | ||
elements: string | ||
required: true | ||
''' | ||
|
||
EXAMPLES = ''' | ||
- name: Convert list of tuples into dictionary | ||
ansible.builtin.set_fact: | ||
dictionary: "{{ ['2.1', '2.10', '2.9'] | middleware_automation.keycloak.version_sort }}" | ||
# Result is ['2.1', '2.9', '2.10'] | ||
''' | ||
|
||
RETURN = ''' | ||
_value: | ||
description: The list of strings sorted by version. | ||
type: list | ||
elements: string | ||
''' | ||
|
||
from ansible_collections.middleware_automation.keycloak.plugins.module_utils.version import LooseVersion | ||
|
||
|
||
def version_sort(value, reverse=False): | ||
'''Sort a list according to loose versions so that e.g. 2.9 is smaller than 2.10''' | ||
return sorted(value, key=LooseVersion, reverse=reverse) | ||
|
||
|
||
class FilterModule(object): | ||
''' Version sort filter ''' | ||
|
||
def filters(self): | ||
return { | ||
'version_sort': version_sort | ||
} |
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,22 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2021, 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 | ||
|
||
"""Provide version object to compare version numbers.""" | ||
|
||
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 # noqa: F401, pylint: disable=unused-import | ||
except ImportError: | ||
try: | ||
from distutils.version import LooseVersion # noqa: F401, pylint: disable=unused-import | ||
except ImportError as exc: | ||
msg = 'To use this plugin or module with ansible-core 2.11, you need to use Python < 3.12 with distutils.version present' | ||
raise_from(ImportError(msg), exc) |
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
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
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