1eb0eee3bc
There are currently 2 issues that prevent using this chart to deploy gitea with a SQLite3 database. 1) The value from *gitea.config.database.HOST* is used to set *db.servicename* when all the databases under *gitea.database.buildIn* are not enabled. This causes a type error during the template processing: `Error: UPGRADE FAILED: template: gitea/templates/gitea/init.yaml:24:20: executing "gitea/templates/gitea/init.yaml" at <include "db.servicename" .>: error calling include: template: gitea/templates/_helpers.tpl:64:31: executing "db.servicename" at <.Values.gitea.config.database.HOST>: wrong type for value; expected string; got interface {}` 2) In *init_gitea.sh*, we use the value *db.servicename* and *db.port* to ping the database. If this database responds to ping, we proceed with the init. The problem here is that *db.port* is not set when all the databases under *gitea.database.buildIn* are disabled. In turn, this raises an error from busybox's *nc*, because no parameter is passed for *PORT*. This causes the init container to go in *CrashLoopBackOff* forever. The simple fix that is proposed in this PR is to check wether or not *.Values.gitea.config.database.DB_TYPE* is set to determine the value *db.servicename*. If *DB_TYPE* is *'sqlite3'*, leave *db.servicename* empty and use that to bypass the database ping. Co-authored-by: Baptiste Covolato <b.covolato@gmail.com> Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/124 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: lafriks <lafriks@noreply.gitea.io> Reviewed-by: luhahn <luhahn@noreply.gitea.io> Co-authored-by: Nakrez <nakrez@noreply.gitea.io> Co-committed-by: Nakrez <nakrez@noreply.gitea.io>
118 lines
3.9 KiB
Smarty
118 lines
3.9 KiB
Smarty
{{/* vim: set filetype=mustache: */}}
|
|
{{/*
|
|
Expand the name of the chart.
|
|
*/}}
|
|
{{- define "gitea.name" -}}
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create a default fully qualified app name.
|
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
If release name contains chart name it will be used as a full name.
|
|
*/}}
|
|
{{- define "gitea.fullname" -}}
|
|
{{- if .Values.fullnameOverride -}}
|
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
|
{{- if contains $name .Release.Name -}}
|
|
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create chart name and version as used by the chart label.
|
|
*/}}
|
|
{{- define "gitea.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Common labels
|
|
*/}}
|
|
{{- define "gitea.labels" -}}
|
|
helm.sh/chart: {{ include "gitea.chart" . }}
|
|
app: {{ include "gitea.name" . }}
|
|
{{ include "gitea.selectorLabels" . }}
|
|
{{- if .Chart.AppVersion }}
|
|
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
|
version: {{ .Chart.AppVersion | quote }}
|
|
{{- end }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Selector labels
|
|
*/}}
|
|
{{- define "gitea.selectorLabels" -}}
|
|
app.kubernetes.io/name: {{ include "gitea.name" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end -}}
|
|
|
|
{{- define "db.servicename" -}}
|
|
{{- if .Values.gitea.database.builtIn.postgresql.enabled -}}
|
|
{{- printf "%s-postgresql" .Release.Name -}}
|
|
{{- else if .Values.gitea.database.builtIn.mysql.enabled -}}
|
|
{{- printf "%s-mysql" .Release.Name -}}
|
|
{{- else if .Values.gitea.database.builtIn.mariadb.enabled -}}
|
|
{{- printf "%s-mariadb" .Release.Name -}}
|
|
{{- else if ne .Values.gitea.config.database.DB_TYPE "sqlite3" -}}
|
|
{{- $parts := split ":" .Values.gitea.config.database.HOST -}}
|
|
{{- printf "%s %s" $parts._0 $parts._1 -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "db.port" -}}
|
|
{{- if .Values.gitea.database.builtIn.postgresql.enabled -}}
|
|
{{ .Values.postgresql.global.postgresql.servicePort }}
|
|
{{- else if .Values.gitea.database.builtIn.mysql.enabled -}}
|
|
{{ .Values.mysql.service.port }}
|
|
{{- else if .Values.gitea.database.builtIn.mariadb.enabled -}}
|
|
{{ .Values.mariadb.primary.service.port }}
|
|
{{- else -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "postgresql.dns" -}}
|
|
{{- printf "%s-postgresql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.postgresql.global.postgresql.servicePort -}}
|
|
{{- end -}}
|
|
|
|
{{- define "mysql.dns" -}}
|
|
{{- printf "%s-mysql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.mysql.service.port | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{- define "mariadb.dns" -}}
|
|
{{- printf "%s-mariadb.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.mariadb.primary.service.port | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{- define "memcached.dns" -}}
|
|
{{- printf "%s-memcached.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.memcached.service.port | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{- define "gitea.default_domain" -}}
|
|
{{- printf "%s-gitea.%s.svc.%s" (include "gitea.fullname" .) .Release.Namespace .Values.clusterDomain | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{- define "gitea.ldap_settings" -}}
|
|
{{- range $key, $val := .Values.gitea.ldap -}}
|
|
{{- if ne $key "enabled" -}}
|
|
{{- if eq $key "port" -}}
|
|
{{- printf "--%s %d " ($key | kebabcase) ($val | int) -}}
|
|
{{- else -}}
|
|
{{- printf "--%s %s " ($key | kebabcase) ($val | quote) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "gitea.oauth_settings" -}}
|
|
{{- range $key, $val := .Values.gitea.oauth -}}
|
|
{{- if ne $key "enabled" -}}
|
|
{{- printf "--%s %s " ($key | kebabcase) ($val | quote) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}} |