Skip to content
Open
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
2 changes: 1 addition & 1 deletion helm/templates/config/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
(include "agentstack.databaseName" .)
| b64enc | quote
}}
{{- if and .Values.postgresql.enabled .Values.postgresql.auth.enablePostgresUser }}
{{- if or (and .Values.postgresql.enabled .Values.postgresql.auth.enablePostgresUser) (and (not .Values.postgresql.enabled) .Values.externalDatabase.adminUser .Values.externalDatabase.adminPassword) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current condition uses or which might lead to unexpected behavior. If postgresql.enabled is true but postgresql.auth.enablePostgresUser is false, and the external database credentials are also provided, the sqlConnectionSuperuser will still be generated, which might not be the intended behavior. Consider using nested and conditions to ensure that the superuser connection string is generated only when either internal PostgreSQL with admin user is enabled, or external database with admin credentials is provided, and internal PostgreSQL is not enabled.

Here's the updated condition:

{{- if or (and .Values.postgresql.enabled .Values.postgresql.auth.enablePostgresUser) (and (not .Values.postgresql.enabled) .Values.externalDatabase.adminUser .Values.externalDatabase.adminPassword) }}

This can be refactored to:

{{- if and (or .Values.postgresql.enabled (and .Values.externalDatabase.adminUser .Values.externalDatabase.adminPassword)) (or .Values.postgresql.auth.enablePostgresUser (not .Values.postgresql.enabled)) }}
{{- if and (or .Values.postgresql.enabled (and .Values.externalDatabase.adminUser .Values.externalDatabase.adminPassword)) (or .Values.postgresql.auth.enablePostgresUser (not .Values.postgresql.enabled)) }}

sqlConnectionSuperuser: {{ printf "postgresql+asyncpg://%s:%s@%s:%s/%s"
(include "agentstack.databaseAdminUser" .)
(include "agentstack.databaseAdminPassword" .)
Expand Down