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>
56 lines
2.0 KiB
YAML
56 lines
2.0 KiB
YAML
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: {{ include "gitea.fullname" . }}-init
|
|
labels:
|
|
{{- include "gitea.labels" . | nindent 4 }}
|
|
type: Opaque
|
|
stringData:
|
|
init_gitea.sh: |-
|
|
#!/bin/bash
|
|
{{- if .Values.initPreScript }}
|
|
# BEGIN: initPreScript
|
|
{{- with .Values.initPreScript -}}
|
|
{{ . | nindent 4}}
|
|
{{- end -}}
|
|
# END: initPreScript
|
|
{{- end }}
|
|
|
|
mkdir -p /data/git/.ssh
|
|
chmod -R 700 /data/git/.ssh
|
|
mkdir -p /data/gitea/conf
|
|
cp /etc/gitea/conf/app.ini /data/gitea/conf/app.ini
|
|
chmod a+rwx /data/gitea/conf/app.ini
|
|
{{- if include "db.servicename" . }}
|
|
nc -v -w2 -z {{ include "db.servicename" . }} {{ include "db.port" . }} && \
|
|
{{- end }}
|
|
su git -c ' \
|
|
set -x; \
|
|
gitea migrate; \
|
|
{{- if and .Values.gitea.admin.username .Values.gitea.admin.password }}
|
|
gitea admin create-user --username {{ .Values.gitea.admin.username }} --password {{ .Values.gitea.admin.password | quote }} --email {{ .Values.gitea.admin.email }} --admin --must-change-password=false \
|
|
|| \
|
|
gitea admin change-password --username {{ .Values.gitea.admin.username }} --password {{ .Values.gitea.admin.password | quote }}; \
|
|
{{- end }}
|
|
{{- if .Values.gitea.ldap.enabled }}
|
|
gitea admin auth add-ldap \
|
|
{{- include "gitea.ldap_settings" . | nindent 6 }} \
|
|
|| \
|
|
( \
|
|
export GITEA_AUTH_ID=$(gitea admin auth list | grep {{ .Values.gitea.ldap.name | quote }} | awk -F " " "{print \$1}"); \
|
|
gitea admin auth update-ldap --id ${GITEA_AUTH_ID} \
|
|
{{- include "gitea.ldap_settings" . | nindent 6 }} \
|
|
) \
|
|
{{- end }}
|
|
{{- if .Values.gitea.oauth.enabled }}
|
|
gitea admin auth add-oauth \
|
|
{{- include "gitea.oauth_settings" . | nindent 6 }} \
|
|
|| \
|
|
( \
|
|
export GITEA_AUTH_ID=$(gitea admin auth list | grep {{ .Values.gitea.oauth.name | quote }} | awk -F " " "{print \$1}"); \
|
|
gitea admin auth update-oauth --id ${GITEA_AUTH_ID} \
|
|
{{- include "gitea.oauth_settings" . | nindent 6 }} \
|
|
) \
|
|
{{- end }}
|
|
'
|