From 28dbdb7dab4778563e61387a5cb1089a710e4221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alin=20Tr=C4=83istaru?= Date: Tue, 21 Jan 2025 19:56:08 +0100 Subject: [PATCH] Fix the default database host value (#8) The default config for db.host is "invidious-postgresql" which only works when the chart is installed with a release name of "invidious". Changed the default db.host value to "${release_name}-postgresql". --- invidious/Chart.yaml | 4 ++-- invidious/templates/_helpers.tpl | 17 +++++++++++++++++ invidious/templates/deployment.yaml | 1 + invidious/templates/secret.yaml | 1 + invidious/values.yaml | 2 +- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/invidious/Chart.yaml b/invidious/Chart.yaml index 5aa9f43..6cb41e0 100644 --- a/invidious/Chart.yaml +++ b/invidious/Chart.yaml @@ -4,7 +4,7 @@ description: Invidious is an alternative front-end to YouTube type: application -version: 2.0.4 +version: 2.0.5 appVersion: v2.20240427 dependencies: @@ -20,7 +20,7 @@ keywords: - proxy - video - privacy - + home: https://invidious.io icon: https://raw.githubusercontent.com/iv-org/invidious/05988c1c49851b7d0094fca16aeaf6382a7f64ab/assets/favicon-32x32.png diff --git a/invidious/templates/_helpers.tpl b/invidious/templates/_helpers.tpl index 1a05abb..022f282 100644 --- a/invidious/templates/_helpers.tpl +++ b/invidious/templates/_helpers.tpl @@ -50,3 +50,20 @@ Selector labels app.kubernetes.io/name: {{ include "invidious.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} + +{{/* +Initialize default values and validate database configuration +*/}} +{{- define "invidious.init-defaults" -}} +{{/* Set default PostgreSQL host if using in-chart PostgreSQL */}} +{{- if .Values.postgresql.enabled }} + {{- if not .Values.config.db.host }} + {{- $_ := set .Values.config.db "host" (printf "%s-postgresql" .Release.Name) }} + {{- end }} +{{- else }} +{{/* Fail if external database host is not provided when in-chart PostgreSQL is disabled */}} + {{- if not .Values.config.db.host }} + {{- fail "config.db.host must be set when postgresql.enabled is false" }} + {{- end }} +{{- end }} +{{- end -}} diff --git a/invidious/templates/deployment.yaml b/invidious/templates/deployment.yaml index 1d3a7cf..a711ee7 100644 --- a/invidious/templates/deployment.yaml +++ b/invidious/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- include "invidious.init-defaults" . }} apiVersion: apps/v1 kind: Deployment metadata: diff --git a/invidious/templates/secret.yaml b/invidious/templates/secret.yaml index 5274238..adbe7cd 100644 --- a/invidious/templates/secret.yaml +++ b/invidious/templates/secret.yaml @@ -1,3 +1,4 @@ +{{- include "invidious.init-defaults" . }} apiVersion: v1 kind: Secret metadata: diff --git a/invidious/values.yaml b/invidious/values.yaml index 8172976..debc6bb 100644 --- a/invidious/values.yaml +++ b/invidious/values.yaml @@ -88,7 +88,7 @@ config: db: user: kemal password: kemal - host: invidious-postgresql + host: "" port: 5432 dbname: invidious port: 3000