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

Add support for aliases for Quadlets

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sagi Shnaidman 2026-05-19 23:26:37 +03:00
parent ab6db3bdb3
commit bbf0a7fe5f
2 changed files with 71 additions and 2 deletions

View file

@ -75,17 +75,19 @@ class Quadlet:
Convert parameter values as per param_map.
"""
processed_params = []
seen_quadlet_keys = set()
for param_key, quadlet_key in self.param_map.items():
if quadlet_key in seen_quadlet_keys:
continue
value = self.custom_params.get(param_key)
if value is not None:
seen_quadlet_keys.add(quadlet_key)
if isinstance(value, list):
# Add an entry for each item in the list
for item in value:
processed_params.append([quadlet_key, item])
else:
if isinstance(value, bool):
value = str(value).lower()
# Add a single entry for the key
processed_params.append([quadlet_key, value])
return processed_params
@ -716,6 +718,7 @@ class ImageQuadlet(Quadlet):
"AllTags": "AllTags",
"arch": "Arch",
"authfile": "AuthFile",
"auth_file": "AuthFile",
"ca_cert_dir": "CertDir",
"creds": "Creds",
"DecryptionKey": "DecryptionKey",

View file

@ -606,6 +606,72 @@
- quad3 is changed
- "'arm64' in quad3.diff.after"
- name: Create quadlet image file with auth_file
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: quay.io/coreos/coreos-installer:latest
state: quadlet
auth_file: /path/to/auth.json
quadlet_dir: /tmp/
quadlet_filename: authfile_test
register: quad_authfile
- name: Check AuthFile line appears exactly once
shell: grep -c 'AuthFile=' /tmp/authfile_test.image
register: authfile_count
- name: Fail if AuthFile appears more than once
assert:
that:
- authfile_count.stdout | int == 1
fail_msg: "AuthFile should appear exactly once, found {{ authfile_count.stdout }} times"
- name: Check AuthFile value is correct
lineinfile:
path: /tmp/authfile_test.image
line: "AuthFile=/path/to/auth.json"
state: present
check_mode: yes
register: authfile_line_check
- name: Fail if AuthFile line is not present
assert:
that:
- authfile_line_check is not changed
- name: Create quadlet image file with authfile alias
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: quay.io/coreos/coreos-installer:latest
state: quadlet
authfile: /path/to/auth2.json
quadlet_dir: /tmp/
quadlet_filename: authfile_alias_test
register: quad_authfile_alias
- name: Check AuthFile line appears exactly once with alias
shell: grep -c 'AuthFile=' /tmp/authfile_alias_test.image
register: authfile_alias_count
- name: Fail if AuthFile appears more than once with alias
assert:
that:
- authfile_alias_count.stdout | int == 1
fail_msg: "AuthFile should appear exactly once, found {{ authfile_alias_count.stdout }} times"
- name: Check AuthFile value is correct with alias
lineinfile:
path: /tmp/authfile_alias_test.image
line: "AuthFile=/path/to/auth2.json"
state: present
check_mode: yes
register: authfile_alias_line_check
- name: Fail if AuthFile line is not present with alias
assert:
that:
- authfile_alias_line_check is not changed
- include_tasks: additional_tests.yml
- include_tasks: test_issue_947.yml