Piped-Kubernetes/charts/apps/piped/templates/backend/configmap.yaml
Skyler Mäntysaari 1ee4d9b717
Support for more backend config options. (#91)
* Support for more backend config options.
* Support for more backend config options, part two.
* Update Chart.yaml
* Update README for chart
2024-05-02 15:51:55 +03:00

105 lines
6.1 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "backend.names.fullname" . }}-config
{{- with (merge (.Values.backend.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }}
{{- end }}
{{- with (merge (.Values.backend.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
data:
config.properties: |
{{- if .Values.backend.config.PORT }}
PORT: {{ .Values.backend.config.PORT }}
{{- else }}
PORT: 8080
{{ end }}
{{- if .Values.backend.config.HTTP_WORKERS }}
HTTP_WORKERS: {{ .Values.backend.config.HTTP_WORKERS }}
{{- else }}
HTTP_WORKERS: 2
{{ end }}
{{- if .Values.backend.config.HTTP_PROXY }}
HTTP_PROXY: {{ .Values.backend.config.HTTP_PROXY }}
{{ end }}
{{- if .Values.backend.config.PROXY_PART }}
PROXY_PART: {{.Values.backend.config.PROXY_PART }}
{{- else if (and .Values.ingress.ytproxy.enabled .Values.ingress.ytproxy.tls) }}
PROXY_PART: https://{{ index (index .Values.ingress.ytproxy.hosts 0) "host" }}
{{- else if .Values.ingress.ytproxy.enabled }}
PROXY_PART: http://{{ index (index .Values.ingress.ytproxy.hosts 0) "host" }}
{{- else }}
{{- fail "PROXY_PART needs to be set in config values or ytproxy ingress must be enabled."}}
{{ end }}
{{- if (and .Values.backend.config.REQWEST_PROXY .Values.backend.config.REQWEST_PROXY_USER .Values.backend.config.REQWEST_PROXY_PASS) }}
REQWEST_PROXY: {{ .Values.backend.config.REQWEST_PROXY }}
REQWEST_PROXY_USER: {{ .Values.backend.config.REQWEST_PROXY_USER }}
REQWEST_PROXY_PASS: {{ .Values.backend.config.REQWEST_PROXY_PASS }}
{{- else if and (not .Values.backend.config.REQWEST_PROXY_USER) (not .Values.backend.config.REQWEST_PROXY_PASS) (.Values.backend.config.REQWEST_PROXY) }}
REQWEST_PROXY: {{ .Values.backend.config.REQWEST_PROXY }}
{{- end }}
{{- if .Values.backend.config.CAPTCHA_BASE_URL }}
CAPTCHA_BASE_URL: {{ .Values.backend.config.CAPTCHA_BASE_URL }}
{{- else if (and .Values.backend.config.CAPTCHA_BASE_URL .Values.backend.config.CAPTCHA_API_KEY) }}
CAPTCHA_BASE_URL: {{ .Values.backend.config.CAPTCHA_BASE_URL }}
CAPTCHA_API_KEY: {{ .Values.backend.config.CAPTCHA_API_KEY }}
{{- end}}
{{- if .Values.backend.config.API_URL }}
API_URL: {{ .Values.backend.config.API_URL }}
{{- else if (and .Values.ingress.backend.enabled .Values.ingress.backend.tls) }}
API_URL: https://{{ index (index .Values.ingress.backend.hosts 0) "host" }}
{{- else if .Values.ingress.backend.enabled }}
API_URL: http://{{ index (index .Values.ingress.backend.hosts 0) "host" }}
{{- else }}
{{- fail "API_URL needs to be set in config values or backend ingress must be enabled."}}
{{ end }}
{{- if .Values.backend.config.FRONTEND_URL }}
FRONTEND_URL: {{.Values.backend.config.FRONTEND_URL }}
{{- else if (and .Values.ingress.main.enabled .Values.ingress.main.tls) }}
FRONTEND_URL: https://{{ index (index .Values.ingress.main.hosts 0) "host" }}
{{- else if .Values.ingress.main.enabled }}
FRONTEND_URL: {{ index (index .Values.ingress.main.hosts 0) "host" }}
{{- else }}
{{- fail "FRONTEND_URL needs to be set in config values or main ingress must be enabled."}}
{{ end }}
COMPROMISED_PASSWORD_CHECK: {{ .Values.backend.config.COMPROMISED_PASSWORD_CHECK | default true }}
DISABLE_REGISTRATION: {{ .Values.backend.config.DISABLE_REGISTRATION | default false }}
FEED_RETENTION: {{ .Values.backend.config.FEED_RETENTION | default 30 | int }}
{{- if and (.Values.backend.config.database) (not .Values.postgresql.enabled) }}
hibernate.connection.url: {{.Values.backend.config.database.connection_url }}
{{- if and (not .Values.backend.config.database.driver_class) (not .Values.backend.config.database.dialect) }}
hibernate.connection.driver_class: org.postgresql.Driver
hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect
{{ end }}
{{- if and (.Values.backend.config.database) (.Values.backend.config.database.driver_class) (.Values.backend.config.database.dialect) (not .Values.postgresql.enabled)}}
hibernate.connection.driver_class: {{.Values.backend.config.database.driver_class }}
hibernate.dialect: {{.Values.backend.config.database.dialect }}
hibernate.connection.username: {{.Values.backend.config.database.username }}
hibernate.connection.password: {{.Values.backend.config.database.password }}
{{ end }}
{{- if and (.Values.backend.config.database.secret) (.Values.backend.config.database.secret.name) }}
hibernate.connection.username: {{ include "common.getValueFromSecret" (dict "Namespace" .Release.Namespace "Name" .Values.backend.config.database.secret.name "Key" (.Values.backend.config.database.secret.username | default "DB_USERNAME")) }}
hibernate.connection.password: {{ include "common.getValueFromSecret" (dict "Namespace" .Release.Namespace "Name" .Values.backend.config.database.secret.name "Key" (.Values.backend.config.database.secret.password | default "DB_PASSWORD")) }}
{{- end }}
{{- else if .Values.postgresql.enabled }}
hibernate.connection.url: jdbc:postgresql://piped-postgresql/{{ .Values.postgresql.auth.database}}
hibernate.connection.driver_class: org.postgresql.Driver
hibernate.connection.username: {{.Values.postgresql.auth.username }}
hibernate.connection.password: {{.Values.postgresql.auth.password }}
{{- else }}
{{- fail "Unable to figure out database configuration for backend configmap."}}
{{- end }}
{{- if .Values.backend.config.SENTRY_DNS }}
SENTRY_DSN: {{.Values.backend.SENTRY_DNS }}
{{- else }}
SENTRY_DSN:
{{- end }}
{{- if (and .Values.backend.config.MATRIX_SERVER .Values.backend.config.MATRIX_TOKEN) }}
MATRIX_SERVER: {{.Values.backend.config.MATRIX_SERVER }}
MATRIX_TOKEN: {{ .Values.backend.config.MATRIX_TOKEN }}
{{- else if (not .Values.backend.config.MATRIX_TOKEN) }}
MATRIX_SERVER: https://matrix-client.matrix.org
{{- end }}