1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-03-21 18:19:07 +00:00

Add --platform option to podman_image

Fix #1003
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sagi Shnaidman 2026-02-27 13:51:38 +02:00 committed by Sergey
parent cc98f4430c
commit 88999e2bcf
4 changed files with 77 additions and 9 deletions

View file

@ -380,6 +380,26 @@
- item.Architecture == "arm"
loop: "{{ imageinfo_arch.images }}"
- name: Pull an image for a specific platform
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: quay.io/coreos/etcd:v3.5.27
platform: linux/amd64
register: pull_platform1
- name: Pull the same image for the same platform
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: quay.io/coreos/etcd:v3.5.27
platform: linux/amd64
register: pull_platform2
- name: Ensure platform pull is idempotent
assert:
that:
- pull_platform1 is changed
- pull_platform2 is not changed
- name: Build Docker image
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
@ -599,9 +619,11 @@
state: absent
loop:
- docker.io/library/ubuntu
- docker.io/library/alpine
- quay.io/sshnaidm1/alpine-sh
- quay.io/coreos/etcd:v3.3.11
- quay.io/coreos/etcd:v3.5.19
- quay.io/coreos/etcd:v3.5.27
- localhost/testimage
- localhost/testimage2
- localhost/testimage2:testtag

View file

@ -48,6 +48,8 @@ class TestPodmanImageModule:
),
# Valid authentication parameters
({"name": "alpine", "username": "testuser", "password": "testpass"}, True),
# Valid platform parameter (issue #1003)
({"name": "alpine", "platform": "linux/amd64"}, True),
],
)
def test_module_parameter_validation(self, test_params, expected_valid):
@ -138,19 +140,22 @@ class TestPodmanImageModule:
mutually_exclusive_combinations = [
({"auth_file": "/path/to/auth", "username": "user"}, True),
({"auth_file": "/path/to/auth", "password": "pass"}, True),
({"arch": "amd64", "platform": "linux/amd64"}, True), # arch and platform
({"username": "user", "password": "pass"}, False), # This should be allowed
({"auth_file": "/path/to/auth"}, False), # This should be allowed
({"platform": "linux/amd64"}, False), # platform alone is allowed
]
for params, should_be_exclusive in mutually_exclusive_combinations:
# This tests the logic of mutual exclusion
has_auth_file = "auth_file" in params
has_credentials = "username" in params or "password" in params
has_arch_and_platform = "arch" in params and "platform" in params
if should_be_exclusive:
assert has_auth_file and has_credentials
assert (has_auth_file and has_credentials) or has_arch_and_platform
else:
assert not (has_auth_file and has_credentials) or not has_auth_file
assert not (has_auth_file and has_credentials) and not has_arch_and_platform
def test_required_together_logic(self):
"""Test that username and password are required together."""