From 4e1e15563825c47514b73695225a9085ca1290b0 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 12 Sep 2024 07:53:20 -0700 Subject: [PATCH] Allow dib_elements key to be a nested list It's highly likely that folks may want to use YAML anchors to build up list of DIB elements. To aid in that, allow the value to be a list of lists and automatically flatton it. Change-Id: I55b9cb16951b51da32f99ca5858b75217951b279 --- roles/build-diskimage/README.rst | 5 ++++- roles/build-diskimage/tasks/main.yaml | 2 +- zuul.d/dib-jobs.yaml | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/build-diskimage/README.rst b/roles/build-diskimage/README.rst index 7d292b365..1e9a1b3d7 100644 --- a/roles/build-diskimage/README.rst +++ b/roles/build-diskimage/README.rst @@ -23,7 +23,7 @@ Example: .. zuul:rolevar:: build_diskimage_command :default: "{{ ensure_dib_command }}" - Path to the build-disk-image command. This defaults to + Path to the build-disk-image command. This defaults to {{ ensure_dib_command }}. as being set by the ensure-dib role. .. zuul:rolevar:: build_diskimage_image_name @@ -42,6 +42,9 @@ Example: List of elements that should be used when creating the disk image. + For ease of use with YAML anchors, this may be provided as a list + of lists which will be flattened automatically. + .. zuul:rolevar:: build_diskimage_environment :type: dict diff --git a/roles/build-diskimage/tasks/main.yaml b/roles/build-diskimage/tasks/main.yaml index 5e4781255..4be0141c9 100644 --- a/roles/build-diskimage/tasks/main.yaml +++ b/roles/build-diskimage/tasks/main.yaml @@ -9,7 +9,7 @@ -o "{{ build_diskimage_image_root }}/{{ build_diskimage_image_name | mandatory }}" -t "{{ build_diskimage_formats | join(',') }}" --logfile "{{ build_diskimage_logs_dir }}/diskimage-{{ build_diskimage_image_name }}.log" - {{ build_diskimage_elements | mandatory | join(' ') }} + {{ build_diskimage_elements | mandatory | flatten | join(' ') }} args: chdir: "{{ build_diskimage_image_root }}" environment: "{{ build_diskimage_environment }}" diff --git a/zuul.d/dib-jobs.yaml b/zuul.d/dib-jobs.yaml index 7f04fe37b..6e6ed9a49 100644 --- a/zuul.d/dib-jobs.yaml +++ b/zuul.d/dib-jobs.yaml @@ -26,6 +26,9 @@ List of elements that should be used when creating the disk image. + For ease of use with YAML anchors, this may be provided as a list + of lists which will be flattened automatically. + .. zuul:jobvar:: build_diskimage_environment :type: dict