diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 9a4f940..8cafd79 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -108,11 +108,11 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} {{- define "gitea.ldap_settings" -}} -{{- if or (not (hasKey .Values.gitea.ldap "bindDn")) (not (hasKey .Values.gitea.ldap "bind-dn")) -}} +{{- if and (not (hasKey .Values.gitea.ldap "bindDn")) (not (hasKey .Values.gitea.ldap "bind-dn")) -}} {{- $_ := set .Values.gitea.ldap "bindDn" "" -}} {{- end -}} -{{- if or (not (hasKey .Values.gitea.ldap "bindPassword")) (not (hasKey .Values.gitea.ldap "bind-password")) -}} +{{- if and (not (hasKey .Values.gitea.ldap "bindPassword")) (not (hasKey .Values.gitea.ldap "bind-password")) -}} {{- $_ := set .Values.gitea.ldap "bindPassword" "" -}} {{- end -}} diff --git a/templates/gitea/init.yaml b/templates/gitea/init.yaml index d23f8df..b44d130 100644 --- a/templates/gitea/init.yaml +++ b/templates/gitea/init.yaml @@ -40,7 +40,7 @@ stringData: {{- end }} set -x; \ gitea migrate; \ - {{- if and .Values.gitea.admin.username .Values.gitea.admin.password }} + {{- if or .Values.gitea.admin.existingSecret (and .Values.gitea.admin.username .Values.gitea.admin.password) }} gitea admin create-user --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}" --email {{ .Values.gitea.admin.email }} --admin --must-change-password=false \ || \ gitea admin change-password --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}" \ diff --git a/templates/gitea/statefulset.yaml b/templates/gitea/statefulset.yaml index d4a16c8..b232478 100644 --- a/templates/gitea/statefulset.yaml +++ b/templates/gitea/statefulset.yaml @@ -63,9 +63,9 @@ spec: name: {{ .Values.gitea.ldap.existingSecret }} {{- else }} - name: GITEA_LDAP_BIND_DN - value: {{ .Values.gitea.ldap.bindDn | quote }} + value: {{ default (index .Values.gitea.ldap "bind-dn") .Values.gitea.ldap.bindDn | quote }} - name: GITEA_LDAP_PASSWORD - value: {{ .Values.gitea.ldap.bindPassword | quote }} + value: {{ default (index .Values.gitea.ldap "bind-password") .Values.gitea.ldap.bindPassword | quote }} {{- end }} {{- if .Values.gitea.admin.existingSecret }} - name: GITEA_ADMIN_USERNAME