From 9233c57aad704943106fd9de0d9c8225691d63a1 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Fri, 24 Oct 2025 17:17:44 +0200 Subject: [PATCH 1/3] Fix the bug in the helm template for envs vars for numbers --- helm_chart/templates/operator.yaml | 8 ++--- .../tests/operator_env_vars_type_test.yaml | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 helm_chart/tests/operator_env_vars_type_test.yaml diff --git a/helm_chart/templates/operator.yaml b/helm_chart/templates/operator.yaml index d047ddb9d..de6a8e280 100644 --- a/helm_chart/templates/operator.yaml +++ b/helm_chart/templates/operator.yaml @@ -159,10 +159,10 @@ spec: {{- $initAppDbImageRepositoryEnv := "INIT_APPDB_IMAGE_REPOSITORY" -}} {{- $agentImageEnv := "AGENT_IMAGE" -}} {{- $mongodbImageEnv := "MONGODB_IMAGE" -}} - {{- $initDatabaseVersion := print .Values.initDatabase.version (.Values.build | default "") -}} - {{- $databaseVersion := print .Values.database.version (.Values.build | default "") -}} - {{- $initOpsManagerVersion := print .Values.initOpsManager.version (.Values.build | default "") -}} - {{- $initAppDbVersion := print .Values.initAppDb.version (.Values.build | default "") -}} + {{- $initDatabaseVersion := print .Values.initDatabase.version (.Values.build | default "") | quote -}} + {{- $databaseVersion := print .Values.database.version (.Values.build | default "") | quote -}} + {{- $initOpsManagerVersion := print .Values.initOpsManager.version (.Values.build | default "") | quote -}} + {{- $initAppDbVersion := print .Values.initAppDb.version (.Values.build | default "") | quote -}} {{- $agentVersion := .Values.agent.version }} - name: IMAGE_PULL_POLICY value: {{ .Values.registry.pullPolicy }} diff --git a/helm_chart/tests/operator_env_vars_type_test.yaml b/helm_chart/tests/operator_env_vars_type_test.yaml new file mode 100644 index 000000000..03c6ac311 --- /dev/null +++ b/helm_chart/tests/operator_env_vars_type_test.yaml @@ -0,0 +1,31 @@ +suite: Environment Variable Quoting Check +templates: + - operator.yaml +tests: + - it: should correctly quote the the value for the env vars for container images + set: + initDatabase.version: 1234 + database.version: 12d3f4 + initOpsManager.version: 1.2.3 + initAppDb.version: abc + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: INIT_DATABASE_VERSION + value: "1234" + - contains: + path: spec.template.spec.containers[0].env + content: + name: DATABASE_VERSION + value: "12d3f4" + - contains: + path: spec.template.spec.containers[0].env + content: + name: INIT_OPS_MANAGER_VERSION + value: "1.2.3" + - contains: + path: spec.template.spec.containers[0].env + content: + name: INIT_APPDB_VERSION + value: "abc" From 9f64a38d2f18ffaf0a89cffcbe843ce678bd5b73 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Fri, 24 Oct 2025 17:46:42 +0200 Subject: [PATCH 2/3] Add a new test --- .../tests/operator_env_vars_type_test.yaml | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/helm_chart/tests/operator_env_vars_type_test.yaml b/helm_chart/tests/operator_env_vars_type_test.yaml index 03c6ac311..e8fcaa3e3 100644 --- a/helm_chart/tests/operator_env_vars_type_test.yaml +++ b/helm_chart/tests/operator_env_vars_type_test.yaml @@ -2,7 +2,7 @@ suite: Environment Variable Quoting Check templates: - operator.yaml tests: - - it: should correctly quote the the value for the env vars for container images + - it: should correctly quote the value for the env vars for container images set: initDatabase.version: 1234 database.version: 12d3f4 @@ -29,3 +29,30 @@ tests: content: name: INIT_APPDB_VERSION value: "abc" + - it: should correctly quote the value for the env vars for container images even when they are passed quoted + set: + initDatabase.version: "1234" + database.version: "12d3f4" + initOpsManager.version: "1.2.3" + initAppDb.version: "abc" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: INIT_DATABASE_VERSION + value: "1234" + - contains: + path: spec.template.spec.containers[0].env + content: + name: DATABASE_VERSION + value: "12d3f4" + - contains: + path: spec.template.spec.containers[0].env + content: + name: INIT_OPS_MANAGER_VERSION + value: "1.2.3" + - contains: + path: spec.template.spec.containers[0].env + content: + name: INIT_APPDB_VERSION + value: "abc" From 54f99b1a1162589f67fca49228728ef4019d8fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kara=C5=9B?= Date: Mon, 27 Oct 2025 12:45:31 +0100 Subject: [PATCH 3/3] Move quote to proper place --- config/manager/manager.yaml | 10 +++++----- helm_chart/templates/operator.yaml | 18 +++++++++--------- public/mongodb-kubernetes-multi-cluster.yaml | 8 ++++---- public/mongodb-kubernetes-openshift.yaml | 10 +++++----- public/mongodb-kubernetes.yaml | 8 ++++---- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 4d047ba27..86983df12 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -69,21 +69,21 @@ spec: - name: INIT_DATABASE_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-database - name: INIT_DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" - name: DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager - name: INIT_OPS_MANAGER_VERSION - value: 1.5.0 + value: "1.5.0" # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-appdb - name: INIT_APPDB_VERSION - value: 1.5.0 + value: "1.5.0" - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE @@ -208,7 +208,7 @@ spec: value: "quay.io/mongodb/mongodb-enterprise-ops-manager-ubi:8.0.14" - name: RELATED_IMAGE_OPS_MANAGER_IMAGE_REPOSITORY_8_0_15 value: "quay.io/mongodb/mongodb-enterprise-ops-manager-ubi:8.0.15" - # since the official server images end with a different suffix we can re-use the same $mongodbImageEnv + # since the official server images end with a different suffix we can re-use the same $mongodbImageEnv - name: RELATED_IMAGE_MONGODB_IMAGE_4_4_0_ubi8 value: "quay.io/mongodb/mongodb-enterprise-server:4.4.0-ubi8" - name: RELATED_IMAGE_MONGODB_IMAGE_4_4_1_ubi8 diff --git a/helm_chart/templates/operator.yaml b/helm_chart/templates/operator.yaml index de6a8e280..ebae9c878 100644 --- a/helm_chart/templates/operator.yaml +++ b/helm_chart/templates/operator.yaml @@ -159,10 +159,10 @@ spec: {{- $initAppDbImageRepositoryEnv := "INIT_APPDB_IMAGE_REPOSITORY" -}} {{- $agentImageEnv := "AGENT_IMAGE" -}} {{- $mongodbImageEnv := "MONGODB_IMAGE" -}} - {{- $initDatabaseVersion := print .Values.initDatabase.version (.Values.build | default "") | quote -}} - {{- $databaseVersion := print .Values.database.version (.Values.build | default "") | quote -}} - {{- $initOpsManagerVersion := print .Values.initOpsManager.version (.Values.build | default "") | quote -}} - {{- $initAppDbVersion := print .Values.initAppDb.version (.Values.build | default "") | quote -}} + {{- $initDatabaseVersion := print .Values.initDatabase.version (.Values.build | default "") -}} + {{- $databaseVersion := print .Values.database.version (.Values.build | default "") -}} + {{- $initOpsManagerVersion := print .Values.initOpsManager.version (.Values.build | default "") -}} + {{- $initAppDbVersion := print .Values.initAppDb.version (.Values.build | default "") -}} {{- $agentVersion := .Values.agent.version }} - name: IMAGE_PULL_POLICY value: {{ .Values.registry.pullPolicy }} @@ -172,21 +172,21 @@ spec: - name: {{ $initDatabaseImageRepositoryEnv }} value: {{ .Values.registry.initDatabase }}/{{ .Values.initDatabase.name }} - name: INIT_DATABASE_VERSION - value: {{ $initDatabaseVersion }} + value: {{ $initDatabaseVersion | quote }} - name: DATABASE_VERSION - value: {{ $databaseVersion }} + value: {{ $databaseVersion | quote }} # Ops Manager - name: {{ $opsManagerImageRepositoryEnv }} value: {{ .Values.registry.opsManager }}/{{ .Values.opsManager.name }} - name: {{ $initOpsManagerImageRepositoryEnv }} value: {{ .Values.registry.initOpsManager }}/{{ .Values.initOpsManager.name }} - name: INIT_OPS_MANAGER_VERSION - value: {{ $initOpsManagerVersion }} + value: {{ $initOpsManagerVersion | quote }} # AppDB - name: {{ $initAppDbImageRepositoryEnv }} value: {{ .Values.registry.initAppDb }}/{{ .Values.initAppDb.name }} - name: INIT_APPDB_VERSION - value: {{ $initAppDbVersion }} + value: {{ $initAppDbVersion | quote }} - name: OPS_MANAGER_IMAGE_PULL_POLICY value: {{ .Values.registry.pullPolicy }} - name: {{ $agentImageEnv }} @@ -260,7 +260,7 @@ spec: - name: RELATED_IMAGE_{{ $opsManagerImageRepositoryEnv }}_{{ $version | replace "." "_" | replace "-" "_" }} value: "{{ $.Values.registry.opsManager }}/{{ $.Values.opsManager.name }}:{{ $version }}" {{- end }} - # since the official server images end with a different suffix we can re-use the same $mongodbImageEnv + # since the official server images end with a different suffix we can re-use the same $mongodbImageEnv {{- range $version := .Values.relatedImages.mongodb }} - name: RELATED_IMAGE_{{ $mongodbImageEnv }}_{{ $version | replace "." "_" | replace "-" "_" }} value: "{{ $.Values.mongodb.repo }}/{{ $.Values.mongodb.name }}:{{ $version }}" diff --git a/public/mongodb-kubernetes-multi-cluster.yaml b/public/mongodb-kubernetes-multi-cluster.yaml index e6d9c5057..2bdb16432 100644 --- a/public/mongodb-kubernetes-multi-cluster.yaml +++ b/public/mongodb-kubernetes-multi-cluster.yaml @@ -380,21 +380,21 @@ spec: - name: INIT_DATABASE_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-database - name: INIT_DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" - name: DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager - name: INIT_OPS_MANAGER_VERSION - value: 1.5.0 + value: "1.5.0" # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-appdb - name: INIT_APPDB_VERSION - value: 1.5.0 + value: "1.5.0" - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE diff --git a/public/mongodb-kubernetes-openshift.yaml b/public/mongodb-kubernetes-openshift.yaml index cd5cc278c..1e2862468 100644 --- a/public/mongodb-kubernetes-openshift.yaml +++ b/public/mongodb-kubernetes-openshift.yaml @@ -375,21 +375,21 @@ spec: - name: INIT_DATABASE_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-database - name: INIT_DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" - name: DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager - name: INIT_OPS_MANAGER_VERSION - value: 1.5.0 + value: "1.5.0" # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-appdb - name: INIT_APPDB_VERSION - value: 1.5.0 + value: "1.5.0" - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE @@ -512,7 +512,7 @@ spec: value: "quay.io/mongodb/mongodb-enterprise-ops-manager-ubi:8.0.14" - name: RELATED_IMAGE_OPS_MANAGER_IMAGE_REPOSITORY_8_0_15 value: "quay.io/mongodb/mongodb-enterprise-ops-manager-ubi:8.0.15" - # since the official server images end with a different suffix we can re-use the same $mongodbImageEnv + # since the official server images end with a different suffix we can re-use the same $mongodbImageEnv - name: RELATED_IMAGE_MONGODB_IMAGE_4_4_0_ubi8 value: "quay.io/mongodb/mongodb-enterprise-server:4.4.0-ubi8" - name: RELATED_IMAGE_MONGODB_IMAGE_4_4_1_ubi8 diff --git a/public/mongodb-kubernetes.yaml b/public/mongodb-kubernetes.yaml index ced86abb4..53de57140 100644 --- a/public/mongodb-kubernetes.yaml +++ b/public/mongodb-kubernetes.yaml @@ -376,21 +376,21 @@ spec: - name: INIT_DATABASE_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-database - name: INIT_DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" - name: DATABASE_VERSION - value: 1.5.0 + value: "1.5.0" # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager - name: INIT_OPS_MANAGER_VERSION - value: 1.5.0 + value: "1.5.0" # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-kubernetes-init-appdb - name: INIT_APPDB_VERSION - value: 1.5.0 + value: "1.5.0" - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE