From 78864b3653807a65b4e9beeee50481bc25a11519 Mon Sep 17 00:00:00 2001 From: lucas-benedito <55454581+lucas-benedito@users.noreply.github.com> Date: Thu, 9 Oct 2025 18:34:50 +0100 Subject: [PATCH] fix: Correct the image_version conditional (#2082) * fix: Correct the image_version conditional When image is set and image_version is unset, the conditional is failing due to the unset variable causes and error. Implemented the correct conditional and added an assert to validate that both variables are set properly when image is set. Signed-off-by: Lucas Benedito --- config/crd/bases/awx.ansible.com_awxs.yaml | 15 +++++++++++++-- roles/installer/tasks/resources_configuration.yml | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 1b90d2ca..afbe19b4 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -36,6 +36,17 @@ spec: metadata: type: object spec: + x-kubernetes-validations: + - rule: "has(self.image) && has(self.image_version) || !has(self.image) && !has(self.image_version)" + message: "Both image and image_version must be set when required" + - rule: "has(self.redis_image) && has(self.redis_image_version) || !has(self.redis_image) && !has(self.redis_image_version)" + message: "Both redis_image and redis_image_version must be set when required" + - rule: "has(self.postgres_image) && has(self.postgres_image_version) || !has(self.postgres_image) && !has(self.postgres_image_version)" + message: "Both postgres_image and postgres_image_version must be set when required" + - rule: >- + has(self.metrics_utility_image) && has(self.metrics_utility_image_version) || + !has(self.metrics_utility_image) && !has(self.metrics_utility_image_version) + message: "Both metrics_utility_image and metrics_utility_image_version must be set when required" properties: deployment_type: description: Name of the deployment type @@ -1845,8 +1856,8 @@ spec: description: "PostgreSQL configuration parameter value" type: string required: - - setting - - value + - setting + - value postgres_data_volume_init: description: Sets permissions on the /var/lib/pgdata/data for postgres container using an init container (not Openshift) type: boolean diff --git a/roles/installer/tasks/resources_configuration.yml b/roles/installer/tasks/resources_configuration.yml index bf395392..d9a36310 100644 --- a/roles/installer/tasks/resources_configuration.yml +++ b/roles/installer/tasks/resources_configuration.yml @@ -224,7 +224,7 @@ _custom_image: "{{ image }}:{{ image_version }}" when: - image | default([]) | length - - image_version is defined or image_version != '' + - image_version is defined and image_version != '' - name: Set AWX app image URL set_fact: @@ -239,7 +239,7 @@ _custom_redis_image: "{{ redis_image }}:{{ redis_image_version }}" when: - redis_image | default([]) | length - - redis_image_version is defined or redis_image_version != '' + - redis_image_version is defined and redis_image_version != '' - name: Set Redis image URL set_fact: