Skip to content

Commit 6b0d94b

Browse files
committed
fix: use csv image verbatim and remove external override
- stop stripping the registry prefix from the csv image reference so mirrored images are used as-is, avoiding double-prefix bugs - remove POSTGRES_IMAGE env var override to keep image resolution internal to the script, eliminating an injection surface - quote the image value in the yaml manifest for safety Signed-off-by: Chaitanya Kulkarni <chkulkar@redhat.com> Made-with: Cursor
1 parent c414df5 commit 6b0d94b

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

scripts/setup-database.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#
1313
# Environment variables:
1414
# NAMESPACE Target namespace (default: opendatahub)
15-
# POSTGRES_IMAGE Override PostgreSQL image (default: resolved from operator CSV,
16-
# falls back to registry.redhat.io/rhel9/postgresql-16:latest)
1715
# POSTGRES_USER Database user (default: maas)
1816
# POSTGRES_DB Database name (default: maas)
1917
# POSTGRES_PASSWORD Database password (default: auto-generated)
@@ -41,8 +39,6 @@ DEFAULT_POSTGRES_IMAGE="registry.redhat.io/rhel9/postgresql-16:latest"
4139

4240
# Resolve the PostgreSQL image from the RHOAI operator CSV's relatedImages.
4341
# Expects the RHOAI operator (or its CSV) to be installed on the cluster.
44-
# Replaces the registry prefix with registry.redhat.io so that IDMS can
45-
# redirect to the correct mirror in disconnected environments.
4642
# Falls back to DEFAULT_POSTGRES_IMAGE if the CSV is not found or the entry
4743
# is missing.
4844
resolve_postgres_image() {
@@ -51,9 +47,7 @@ resolve_postgres_image() {
5147
-o jsonpath='{.items[0].spec.relatedImages[?(@.name=="postgresql_16_image")].image}' 2>/dev/null) || true
5248

5349
if [[ -n "${csv_image}" ]]; then
54-
# Strip the registry host and prepend the canonical registry.redhat.io
55-
# e.g., bastion.example.com:8443/rhel9/postgresql-16@sha256:abc → registry.redhat.io/rhel9/postgresql-16@sha256:abc
56-
echo "registry.redhat.io/${csv_image#*/}"
50+
echo "${csv_image}"
5751
else
5852
echo "${DEFAULT_POSTGRES_IMAGE}"
5953
fi
@@ -97,9 +91,7 @@ fi
9791
echo " Creating PostgreSQL deployment..."
9892
echo " ⚠️ Using POC configuration (ephemeral storage)"
9993

100-
# Allow explicit override via POSTGRES_IMAGE env var; otherwise resolve from
101-
# the operator CSV, falling back to the default :latest tag.
102-
POSTGRES_IMAGE="${POSTGRES_IMAGE:-$(resolve_postgres_image)}"
94+
POSTGRES_IMAGE="$(resolve_postgres_image)"
10395
if [[ "${POSTGRES_IMAGE}" == "${DEFAULT_POSTGRES_IMAGE}" ]]; then
10496
echo " Using default PostgreSQL image (operator CSV not available)"
10597
else
@@ -141,7 +133,7 @@ spec:
141133
spec:
142134
containers:
143135
- name: postgres
144-
image: ${POSTGRES_IMAGE}
136+
image: "${POSTGRES_IMAGE}"
145137
env:
146138
- name: POSTGRESQL_USER
147139
valueFrom:

0 commit comments

Comments
 (0)