Skip to content

Commit

Permalink
Final fix
Browse files Browse the repository at this point in the history
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
  • Loading branch information
sshnaidm committed Apr 12, 2024
1 parent d6e9df2 commit 3a0ad23
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 42 deletions.
4 changes: 2 additions & 2 deletions plugins/module_utils/podman/podman_container_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from ansible_collections.containers.podman.plugins.module_utils.podman.common import delete_systemd
from ansible_collections.containers.podman.plugins.module_utils.podman.common import normalize_signal
from ansible_collections.containers.podman.plugins.module_utils.podman.common import ARGUMENTS_OPTS_DICT
from .quadlet import create_quadlet_state
from .quadlet import ContainerQuadlet
from ansible_collections.containers.podman.plugins.module_utils.podman.quadlet import create_quadlet_state
from ansible_collections.containers.podman.plugins.module_utils.podman.quadlet import ContainerQuadlet


__metaclass__ = type
Expand Down
12 changes: 7 additions & 5 deletions plugins/module_utils/podman/quadlet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024 Sagi Shnaidman
# Copyright (c) 2024 Sagi Shnaidman (@sshnaidm)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
Expand Down Expand Up @@ -29,7 +29,7 @@ def custom_prepare_params(self, params: dict) -> dict:

def prepare_params(self) -> dict:
"""
Convert parameter values as per param_map using a dictionary comprehension.
Convert parameter values as per param_map.
"""
processed_params = []
for param_key, quadlet_key in self.param_map.items():
Expand Down Expand Up @@ -481,7 +481,7 @@ def __init__(self, params: dict):

def custom_prepare_params(self, params: dict) -> dict:
"""
Custom parameter processing for pod-specific parameters.
Custom parameter processing for volume-specific parameters.
"""
# Work on params in params_map and convert them to a right form
params["global_args"] = []
Expand Down Expand Up @@ -521,7 +521,7 @@ def __init__(self, params: dict):

def custom_prepare_params(self, params: dict) -> dict:
"""
Custom parameter processing for pod-specific parameters.
Custom parameter processing for kube-specific parameters.
"""
# Work on params in params_map and convert them to a right form
params["global_args"] = []
Expand Down Expand Up @@ -557,7 +557,7 @@ def __init__(self, params: dict):

def custom_prepare_params(self, params: dict) -> dict:
"""
Custom parameter processing for pod-specific parameters.
Custom parameter processing for image-specific parameters.
"""
# Work on params in params_map and convert them to a right form
params["global_args"] = []
Expand All @@ -572,6 +572,7 @@ def custom_prepare_params(self, params: dict) -> dict:


def check_quadlet_directory(module, quadlet_dir):
'''Check if the directory exists and is writable. If not, fail the module.'''
if not os.path.exists(quadlet_dir):
try:
os.makedirs(quadlet_dir)
Expand All @@ -584,6 +585,7 @@ def check_quadlet_directory(module, quadlet_dir):


def create_quadlet_state(module, issuer):
'''Create a quadlet file for the specified issuer.'''
class_map = {
"container": ContainerQuadlet,
"network": NetworkQuadlet,
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/podman_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@
type: bool
quadlet_dir:
description:
- Path to the quadlet file to write.
- Path to the directory to write quadlet file in.
type: path
quadlet_filename:
description:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/podman_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
- ostree
quadlet_dir:
description:
- Path to the quadlet file to be created.
- Path to the directory to write quadlet file in.
type: path
required: false
quadlet_filename:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/podman_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
default: false
quadlet_dir:
description:
- Path to the quadlet file to be created.
- Path to the directory to write quadlet file in.
type: path
required: false
quadlet_filename:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/podman_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
type: str
quadlet_dir:
description:
- Path to the quadlet file to be created.
- Path to the directory to write quadlet file in.
type: path
required: false
quadlet_filename:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/podman_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
- ports
quadlet_dir:
description:
- Path to the quadlet file to write.
- Path to the directory to write quadlet file in.
type: path
quadlet_filename:
description:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/podman_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
default: False
quadlet_dir:
description:
- Path to the quadlet file to be created.
- Path to the directory to write quadlet file in.
type: path
required: false
quadlet_filename:
Expand Down
58 changes: 29 additions & 29 deletions tests/integration/targets/podman_container/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
fail_msg: No image test failed!
success_msg: No image test passed!

# - name: Ensure image doesn't exist
# containers.podman.podman_image:
# executable: "{{ test_executable | default('podman') }}"
# name: alpine:3.7
# state: absent
- name: Ensure image doesn't exist
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: alpine:3.7
state: absent

- name: Check pulling image
containers.podman.podman_container:
Expand All @@ -83,30 +83,30 @@
command: sleep 1d
register: image

# - name: Check using already pulled image
# containers.podman.podman_container:
# executable: "{{ test_executable | default('podman') }}"
# name: container2
# image: alpine:3.7
# state: started
# command: sleep 1d
# register: image2

# - name: Check output is correct
# assert:
# that:
# - image is changed
# - image.container is defined
# - image.container['State']['Running']
# - "'pulled image alpine:3.7' in image.actions"
# - "'started container' in image.actions"
# - image2 is changed
# - image2.container is defined
# - image2.container['State']['Running']
# - "'pulled image alpine:3.7' not in image2.actions"
# - "'started container2' in image2.actions"
# fail_msg: Pulling image test failed!
# success_msg: Pulling image test passed!
- name: Check using already pulled image
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container2
image: alpine:3.7
state: started
command: sleep 1d
register: image2

- name: Check output is correct
assert:
that:
- image is changed
- image.container is defined
- image.container['State']['Running']
- "'pulled image alpine:3.7' in image.actions"
- "'started container' in image.actions"
- image2 is changed
- image2.container is defined
- image2.container['State']['Running']
- "'pulled image alpine:3.7' not in image2.actions"
- "'started container2' in image2.actions"
fail_msg: Pulling image test failed!
success_msg: Pulling image test passed!

- name: Check failed image pull
containers.podman.podman_container:
Expand Down

0 comments on commit 3a0ad23

Please sign in to comment.