Skip to content

Commit

Permalink
Add ability to configure dbport through values.yaml (#178)
Browse files Browse the repository at this point in the history
* Add ability to configure dbport through values.yaml

* fix: codegen

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
Co-authored-by: Aleksandr Sokolov <s0ko1ex@yandex-team.ru>
Co-authored-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 0605bcf commit b10ded4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions charts/reports-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ helm install reports-server --namespace reports-server --create-namespace report
| config.db.secretName | string | `""` | If set, database connection information will be read from the Secret with this name. Overrides `db.host`, `db.name`, `db.user`, and `db.password`. |
| config.db.host | string | `""` | Database host |
| config.db.hostSecretKeyName | string | `"host"` | The database host will be read from this `key` in the specified Secret, when `db.secretName` is set. |
| config.db.port | int | `5432` | Database port |
| config.db.portSecretKeyName | string | `"port"` | The database port will be read from this `key` in the specified Secret, when `db.secretName` is set. |
| config.db.name | string | `"reportsdb"` | Database name |
| config.db.dbNameSecretKeyName | string | `"dbname"` | The database name will be read from this `key` in the specified Secret, when `db.secretName` is set. |
| config.db.user | string | `"postgres"` | Database user |
Expand Down
8 changes: 8 additions & 0 deletions charts/reports-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ Database config is injected into the environment, if a secret ref is set. Otherw
{{- end }}
{{- end }}

{{- define "reports-server.dbPort" -}}
{{- if .Values.config.db.secretName }}
{{- printf "%s" "$(DB_PORT)" }}
{{- else }}
{{- .Values.config.db.port }}
{{- end }}
{{- end }}

{{- define "reports-server.dbName" -}}
{{- if .Values.config.db.secretName }}
{{- printf "%s" "$(DB_DATABASE)" }}
Expand Down
8 changes: 7 additions & 1 deletion charts/reports-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ spec:
- --debug
{{- else }}
- --dbhost={{ include "reports-server.dbHost" . }}
- --dbname={{ include "reports-server.dbName" . }}
- --dbport={{ include "reports-server.dbPort" . }}
- --dbuser={{ include "reports-server.dbUser" . }}
- --dbpassword={{ include "reports-server.dbPassword" . }}
- --dbname={{ include "reports-server.dbName" . }}
- --dbsslmode={{ .Values.config.db.sslmode }}
- --dbsslrootcert={{ .Values.config.db.sslrootcert }}
- --dbsslkey={{ .Values.config.db.sslkey }}
Expand All @@ -61,6 +62,11 @@ spec:
secretKeyRef:
key: {{ .Values.config.db.hostSecretKeyName }}
name: {{ .Values.config.db.secretName }}
- name: DB_PORT
valueFrom:
secretKeyRef:
key: {{ .Values.config.db.portSecretKeyName }}
name: {{ .Values.config.db.secretName }}
- name: DB_DATABASE
valueFrom:
secretKeyRef:
Expand Down
5 changes: 5 additions & 0 deletions charts/reports-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ config:
# -- The database host will be read from this `key` in the specified Secret, when `db.secretName` is set.
hostSecretKeyName: "host"

# -- Database port
port: 5432
# -- The database port will be read from this `key` in the specified Secret, when `db.secretName` is set.
portSecretKeyName: "port"

# -- Database name
name: reportsdb
# -- The database name will be read from this `key` in the specified Secret, when `db.secretName` is set.
Expand Down
3 changes: 2 additions & 1 deletion config/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,10 @@ spec:
- name: reports-server
args:
- --dbhost=reports-server-postgresql.reports-server
- --dbname=reportsdb
- --dbport=5432
- --dbuser=postgres
- --dbpassword=reports
- --dbname=reportsdb
- --dbsslmode=disable
- --dbsslrootcert=
- --dbsslkey=
Expand Down

0 comments on commit b10ded4

Please sign in to comment.