Skip to content

[release-1.10] fix(values): consistent usage of postgresql.adminPasswordKey (#44) - #404

Merged
openshift-merge-bot[bot] merged 3 commits into
redhat-developer:release-1.10from
rm3l:cherry-pick/release-1.10/consistent-usage-of-postgresql-adminPasswordKey
May 18, 2026
Merged

[release-1.10] fix(values): consistent usage of postgresql.adminPasswordKey (#44)#404
openshift-merge-bot[bot] merged 3 commits into
redhat-developer:release-1.10from
rm3l:cherry-pick/release-1.10/consistent-usage-of-postgresql-adminPasswordKey

Conversation

@rm3l

@rm3l rm3l commented May 18, 2026

Copy link
Copy Markdown
Member

Manual cherry-pick of #44

…developer#44)

* fix(values): consistent usage of postgresql.adminPasswordKey

* fix(backstage): consistent usage of postgresql.adminPasswordKey

Replace hard-coded `postgres-password` key in POSTGRESQL_ADMIN_PASSWORD
env vars with the new `rhdh.postgresql.adminPasswordKey` helper, so
overriding `upstream.postgresql.auth.secretKeys.adminPasswordKey` is
consistently respected by both the Backstage and PostgreSQL containers.

---------

Co-authored-by: Corey Daley <cdaley@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Fortune Ndlovu <fndlovu@redhat.com>
@rm3l
rm3l requested a review from a team as a code owner May 18, 2026 07:06
@rhdh-qodo-merge

rhdh-qodo-merge Bot commented May 18, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0)

Grey Divider


Advisory comments

1. Overcomplex Values access 🐞 Bug ⚙ Maintainability
Description
The new rhdh.postgresql.adminPasswordKey helper uses deeply-nested parenthesized .Values
dereferences, which is difficult to read and easy to mis-edit, increasing the risk of future
render-time mistakes. The same file already uses safer, clearer patterns (default dict, hasKey)
elsewhere, so this helper stands out as an unnecessary maintenance hazard.
Code

charts/backstage/templates/_helpers.tpl[R41-50]

+{{- define "rhdh.postgresql.adminPasswordKey" -}}
+    {{- if ((((((.Values).global).postgresql).auth).secretKeys).adminPasswordKey) -}}
+        {{- .Values.global.postgresql.auth.secretKeys.adminPasswordKey -}}
+    {{- else if (((((.Values).postgresql).auth).secretKeys).adminPasswordKey) -}}
+        {{- .Values.postgresql.auth.secretKeys.adminPasswordKey -}}
+    {{- else if ((((.Values).auth).secretKeys).adminPasswordKey) -}}
+        {{- .Values.auth.secretKeys.adminPasswordKey -}}
+    {{- else -}}
+        postgres-password
+    {{- end -}}
Relevance

⭐ Low

Repo already uses similar nested parenthesized .Values patterns in _helpers.tpl and merged them (PR
#44, #291).

PR-#44
PR-#291

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper is currently implemented with long, nested parenthesized dereferences, making it hard to
understand and modify safely. In the same helpers file, other logic (e.g., the Lightspeed helper)
already uses clearer defensive patterns (default dict, hasKey), demonstrating a more
maintainable approach is established in this codebase.

charts/backstage/templates/_helpers.tpl[38-51]
charts/backstage/templates/_helpers.tpl[108-116]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`rhdh.postgresql.adminPasswordKey` is implemented with very deep parenthesized `.Values` access chains, which is hard to read and makes future changes risky.

### Issue Context
This helper is intended to support multiple call contexts (umbrella chart, upstream/backstage subchart, and the bitnami/postgresql subchart) by checking multiple possible value paths.

### Fix Focus Areas
- Refactor the helper to use `dig` + `coalesce` (or `dig` + `default`) to express precedence clearly and avoid the long nested parentheses.
- Keep the same precedence order:
 1) `global.postgresql.auth.secretKeys.adminPasswordKey`
 2) `postgresql.auth.secretKeys.adminPasswordKey`
 3) `auth.secretKeys.adminPasswordKey`
 4) fallback constant

Suggested shape (example):
```tpl
{{- define "rhdh.postgresql.adminPasswordKey" -}}
{{- coalesce
     (dig "global" "postgresql" "auth" "secretKeys" "adminPasswordKey" .Values)
     (dig "postgresql" "auth" "secretKeys" "adminPasswordKey" .Values)
     (dig "auth" "secretKeys" "adminPasswordKey" .Values)
     "postgres-password"
-}}
{{- end -}}
```

- charts/backstage/templates/_helpers.tpl[38-51]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@rm3l rm3l added the lgtm label May 18, 2026
@rhdh-qodo-merge

Copy link
Copy Markdown

Review Summary by Qodo

Consistent usage of postgresql.adminPasswordKey across containers

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Add new helper template for consistent PostgreSQL admin password key resolution
• Replace hard-coded postgres-password key with helper in Backstage container
• Replace hard-coded postgres-password key with helper in PostgreSQL container
• Bump chart version to 5.12.2
Diagram
flowchart LR
  A["Hard-coded postgres-password keys"] -->|"Replace with helper"| B["rhdh.postgresql.adminPasswordKey template"]
  B -->|"Supports override"| C["upstream.postgresql.auth.secretKeys.adminPasswordKey"]
  B -->|"Applied to"| D["Backstage container env"]
  B -->|"Applied to"| E["PostgreSQL container env"]
Loading

Grey Divider

File Changes

1. charts/backstage/Chart.yaml ⚙️ Configuration changes +1/-1

Bump chart version to 5.12.2

• Increment chart version from 5.12.1 to 5.12.2

charts/backstage/Chart.yaml


2. charts/backstage/README.md 📝 Documentation +2/-2

Update documentation version references

• Update version badge from 5.12.1 to 5.12.2
• Update helm install command example to use version 5.12.2

charts/backstage/README.md


3. charts/backstage/templates/_helpers.tpl ✨ Enhancement +15/-0

Add PostgreSQL admin password key helper template

• Add new rhdh.postgresql.adminPasswordKey helper template
• Supports global and local PostgreSQL configuration overrides
• Falls back to default postgres-password key if not configured
• Checks multiple configuration paths in priority order

charts/backstage/templates/_helpers.tpl


View more (2)
4. charts/backstage/values.schema.json 🐞 Bug fix +1/-1

Use helper for PostgreSQL password key in schema

• Replace hard-coded postgres-password key with rhdh.postgresql.adminPasswordKey helper
• Applied to Backstage container POSTGRESQL_ADMIN_PASSWORD environment variable

charts/backstage/values.schema.json


5. charts/backstage/values.yaml 🐞 Bug fix +2/-2

Use helper for PostgreSQL password keys in values

• Replace hard-coded postgres-password key with rhdh.postgresql.adminPasswordKey helper in
 Backstage container
• Replace hard-coded postgres-password key with rhdh.postgresql.adminPasswordKey helper in
 PostgreSQL container
• Ensures consistent handling of admin password key across both containers

charts/backstage/values.yaml


Grey Divider

Qodo Logo

@rhdh-qodo-merge rhdh-qodo-merge Bot added documentation Improvements or additions to documentation bug_fix labels May 18, 2026
@openshift-ci openshift-ci Bot removed the lgtm label May 18, 2026
@openshift-ci

openshift-ci Bot commented May 18, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@sonarqubecloud

Copy link
Copy Markdown

@rm3l rm3l added the lgtm label May 18, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 1d250ee into redhat-developer:release-1.10 May 18, 2026
6 checks passed
@rm3l
rm3l deleted the cherry-pick/release-1.10/consistent-usage-of-postgresql-adminPasswordKey branch May 18, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug_fix documentation Improvements or additions to documentation lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants