mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
fix diff calculation for lower/upper cases (#115)
* fix diff calculation * fix formatting * fix formatting * removed unused import statements * add missing requirement doc
This commit is contained in:
parent
9a7b4d7172
commit
1bd3b70de6
5 changed files with 26 additions and 12 deletions
|
|
@ -17,3 +17,12 @@ def run_podman_command(module, executable='podman', args=None, expected_rc=0, ig
|
|||
msg='Failed to run {command} {args}: {err}'.format(
|
||||
command=command, args=args, err=err))
|
||||
return rc, out, err
|
||||
|
||||
|
||||
def lower_keys(x):
|
||||
if isinstance(x, list):
|
||||
return [lower_keys(v) for v in x]
|
||||
elif isinstance(x, dict):
|
||||
return dict((k.lower(), lower_keys(v)) for k, v in x.items())
|
||||
else:
|
||||
return x
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ notes: []
|
|||
description:
|
||||
- Start, stop, restart and manage Podman containers
|
||||
requirements:
|
||||
- "Podman installed on host"
|
||||
- podman
|
||||
- pyyaml
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
|
|
@ -834,6 +835,8 @@ import yaml # noqa: F402
|
|||
from ansible.module_utils.basic import AnsibleModule # noqa: F402
|
||||
from ansible.module_utils._text import to_bytes, to_native # noqa: F402
|
||||
|
||||
from ansible_collections.containers.podman.plugins.module_utils.podman.common import lower_keys
|
||||
|
||||
|
||||
class PodmanModuleParams:
|
||||
"""Creates list of arguments for podman CLI command.
|
||||
|
|
@ -1306,8 +1309,8 @@ class PodmanContainerDiff:
|
|||
self.module = module
|
||||
self.version = podman_version
|
||||
self.default_dict = None
|
||||
self.info = yaml.safe_load(json.dumps(info).lower())
|
||||
self.image_info = yaml.safe_load(json.dumps(image_info).lower())
|
||||
self.info = lower_keys(info)
|
||||
self.image_info = lower_keys(image_info)
|
||||
self.params = self.defaultize()
|
||||
self.diff = {'before': {}, 'after': {}}
|
||||
self.non_idempotent = {
|
||||
|
|
@ -1496,7 +1499,7 @@ class PodmanContainerDiff:
|
|||
after = before.copy()
|
||||
if self.params['env']:
|
||||
after.update({
|
||||
str(k).lower(): str(v).lower()
|
||||
k: v
|
||||
for k, v in self.params['env'].items()
|
||||
})
|
||||
return self._diff_update_and_compare('env', before, after)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ description:
|
|||
- Manage podman networks with podman network command.
|
||||
requirements:
|
||||
- podman
|
||||
- pyyaml
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
|
|
@ -144,11 +143,12 @@ network:
|
|||
# noqa: F402
|
||||
import json # noqa: F402
|
||||
from distutils.version import LooseVersion # noqa: F402
|
||||
import yaml # noqa: F402
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule # noqa: F402
|
||||
from ansible.module_utils._text import to_bytes, to_native # noqa: F402
|
||||
|
||||
from ansible_collections.containers.podman.plugins.module_utils.podman.common import lower_keys
|
||||
|
||||
|
||||
class PodmanNetworkModuleParams:
|
||||
"""Creates list of arguments for podman CLI command.
|
||||
|
|
@ -247,7 +247,7 @@ class PodmanNetworkDiff:
|
|||
self.module = module
|
||||
self.version = podman_version
|
||||
self.default_dict = None
|
||||
self.info = yaml.safe_load(json.dumps(info).lower())
|
||||
self.info = lower_keys(info)
|
||||
self.params = self.defaultize()
|
||||
self.diff = {'before': {}, 'after': {}}
|
||||
self.non_idempotent = {}
|
||||
|
|
|
|||
|
|
@ -218,11 +218,12 @@ EXAMPLES = '''
|
|||
# noqa: F402
|
||||
import json # noqa: F402
|
||||
from distutils.version import LooseVersion # noqa: F402
|
||||
import yaml # noqa: F402
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule # noqa: F402
|
||||
from ansible.module_utils._text import to_bytes, to_native # noqa: F402
|
||||
|
||||
from ansible_collections.containers.podman.plugins.module_utils.podman.common import lower_keys
|
||||
|
||||
|
||||
class PodmanPodModuleParams:
|
||||
"""Creates list of arguments for podman CLI command.
|
||||
|
|
@ -390,8 +391,8 @@ class PodmanPodDiff:
|
|||
self.module = module
|
||||
self.version = podman_version
|
||||
self.default_dict = None
|
||||
self.info = yaml.safe_load(json.dumps(info).lower())
|
||||
self.infra_info = yaml.safe_load(json.dumps(infra_info).lower())
|
||||
self.info = lower_keys(info)
|
||||
self.infra_info = lower_keys(infra_info)
|
||||
self.params = self.defaultize()
|
||||
self.diff = {'before': {}, 'after': {}}
|
||||
self.non_idempotent = {}
|
||||
|
|
|
|||
|
|
@ -96,11 +96,12 @@ EXAMPLES = '''
|
|||
# noqa: F402
|
||||
import json # noqa: F402
|
||||
from distutils.version import LooseVersion # noqa: F402
|
||||
import yaml # noqa: F402
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule # noqa: F402
|
||||
from ansible.module_utils._text import to_bytes, to_native # noqa: F402
|
||||
|
||||
from ansible_collections.containers.podman.plugins.module_utils.podman.common import lower_keys
|
||||
|
||||
|
||||
class PodmanVolumeModuleParams:
|
||||
"""Creates list of arguments for podman CLI command.
|
||||
|
|
@ -190,7 +191,7 @@ class PodmanVolumeDiff:
|
|||
self.module = module
|
||||
self.version = podman_version
|
||||
self.default_dict = None
|
||||
self.info = yaml.safe_load(json.dumps(info).lower())
|
||||
self.info = lower_keys(info)
|
||||
self.params = self.defaultize()
|
||||
self.diff = {'before': {}, 'after': {}}
|
||||
self.non_idempotent = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue