Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,24 @@ Resolution order:
The image name ("mongodb-community-server") and suffix ("-ubi8") are pinned
because the operator hardcodes those for MongoDBCommunity resources regardless
of the chart's other mongodb.* values.

An existing "-ubi8" suffix on mongodbCommunity.version is trimmed before the
suffix is re-appended, so the append is idempotent. The suffix is defined once
($suffix) and used for both the trim and the append, so they can't drift if it
ever needs to change. This lets private-registry
users (whose mirror only carries "-ubi8" tags, and whose operator consumes the
CR spec.version verbatim) set mongodbCommunity.version: "8.0.20-ubi8" once and
drive both the CR and this init image from that single value — no separate
initContainer.mongodb.image override needed.
*/}}
{{- define "appsmith.mongoInitContainerImage" -}}
{{- if ((.Values.initContainer).mongodb).image -}}
{{- .Values.initContainer.mongodb.image -}}
{{- else -}}
{{- $repo := ((.Values.mongodbOperator).mongodb).repo | default "quay.io/mongodb" -}}
{{- printf "%s/mongodb-community-server:%s-ubi8" $repo .Values.mongodbCommunity.version -}}
{{- $suffix := "-ubi8" -}}
{{- $ver := .Values.mongodbCommunity.version | toString | trimSuffix $suffix -}}
{{- printf "%s/mongodb-community-server:%s%s" $repo $ver $suffix -}}
{{- end -}}
{{- end -}}

Expand Down
23 changes: 23 additions & 0 deletions deploy/helm/tests/mongodb_operator_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ tests:
path: spec.version
value: "6.0.27"

- name: CR should carry the -ubi8 version verbatim (private-registry single-value case)
set:
mongodbCommunity.enabled: true
mongodbCommunity.version: "8.0.20-ubi8"
asserts:
- equal:
path: spec.version
value: "8.0.20-ubi8"

- name: should set correct user roles
set:
mongodbCommunity.enabled: true
Expand Down Expand Up @@ -184,6 +193,20 @@ tests:
count: 1
any: true

- name: should not double-append -ubi8 when version already carries it
set:
mongodb.enabled: false
mongodbCommunity.enabled: true
mongodbCommunity.version: "8.0.20-ubi8"
asserts:
- contains:
path: spec.template.spec.initContainers
content:
name: mongo-init-container
image: "quay.io/mongodb/mongodb-community-server:8.0.20-ubi8"
count: 1
any: true

- name: should inject APPSMITH_DB_URL from secret in operator-only mode
set:
mongodb.enabled: false
Expand Down
5 changes: 5 additions & 0 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ mongodbCommunity:
# @section -- MongoDB Community Operator
name: "" # @schema maxLength: 60; pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
## @param mongodbCommunity.version MongoDB version to deploy
## On a private registry that only mirrors "-ubi8" tags, set this to
## "8.0.20-ubi8": the operator consumes the CR spec.version verbatim, and the
## init-container helper trims the duplicate suffix, so no
## initContainer.mongodb.image override is needed. Leave it bare ("8.0.20")
## for the official registry, where the operator auto-appends "-ubi8".
# -- MongoDB version to deploy
# @section -- MongoDB Community Operator
version: "8.0.20"
Expand Down
Loading