2019-12-12 13:38:31 -05:00
|
|
|
{{/* vim: set filetype=mustache: */}}
|
|
|
|
{{/*
|
|
|
|
Expand the name of the chart.
|
|
|
|
*/}}
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- define "gitea.name" -}}
|
2019-12-12 13:38:31 -05:00
|
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Create a default fully qualified app name.
|
2020-08-23 17:56:55 +00:00
|
|
|
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.
|
2019-12-12 13:38:31 -05:00
|
|
|
*/}}
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- define "gitea.fullname" -}}
|
|
|
|
{{- if .Values.fullnameOverride -}}
|
|
|
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
|
|
{{- else -}}
|
2019-12-12 13:38:31 -05:00
|
|
|
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- 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 -}}
|
|
|
|
|
2021-04-29 17:12:48 +08:00
|
|
|
{{/*
|
|
|
|
Create image name and tag used by the deployment.
|
|
|
|
*/}}
|
|
|
|
{{- define "gitea.image" -}}
|
2022-06-09 18:55:08 +08:00
|
|
|
{{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}}
|
2021-04-29 17:12:48 +08:00
|
|
|
{{- $name := .Values.image.repository -}}
|
2022-03-01 22:55:44 +08:00
|
|
|
{{- $tag := .Values.image.tag | default .Chart.AppVersion -}}
|
2021-04-29 17:12:48 +08:00
|
|
|
{{- $rootless := ternary "-rootless" "" (.Values.image.rootless) -}}
|
2022-06-09 18:55:08 +08:00
|
|
|
{{- if $registry -}}
|
|
|
|
{{- printf "%s/%s:%s%s" $registry $name $tag $rootless -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- printf "%s:%s%s" $name $tag $rootless -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Docker Image Registry Secret Names evaluating values as templates
|
|
|
|
*/}}
|
|
|
|
{{- define "gitea.images.pullSecrets" -}}
|
|
|
|
{{- $pullSecrets := .Values.imagePullSecrets -}}
|
|
|
|
{{- range .Values.global.imagePullSecrets -}}
|
|
|
|
{{- $pullSecrets = append $pullSecrets (dict "name" .) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if (not (empty $pullSecrets)) }}
|
|
|
|
imagePullSecrets:
|
|
|
|
{{ toYaml $pullSecrets }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Storage Class
|
|
|
|
*/}}
|
|
|
|
{{- define "gitea.persistence.storageClass" -}}
|
|
|
|
{{- $storageClass := .Values.global.storageClass | default .Values.persistence.storageClass }}
|
|
|
|
{{- if $storageClass }}
|
|
|
|
storageClassName: {{ $storageClass | quote }}
|
|
|
|
{{- end }}
|
2021-04-29 17:12:48 +08:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-08-23 17:56:55 +00:00
|
|
|
{{/*
|
|
|
|
Common labels
|
|
|
|
*/}}
|
|
|
|
{{- define "gitea.labels" -}}
|
|
|
|
helm.sh/chart: {{ include "gitea.chart" . }}
|
2021-03-01 20:20:55 +08:00
|
|
|
app: {{ include "gitea.name" . }}
|
2020-08-23 17:56:55 +00:00
|
|
|
{{ include "gitea.selectorLabels" . }}
|
2022-03-01 22:55:44 +08:00
|
|
|
app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
|
|
|
|
version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
|
2020-08-23 17:56:55 +00:00
|
|
|
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 -}}
|
|
|
|
|
2020-09-28 23:26:06 +00:00
|
|
|
{{- define "postgresql.dns" -}}
|
2020-10-30 01:08:58 +08:00
|
|
|
{{- printf "%s-postgresql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.postgresql.global.postgresql.servicePort -}}
|
2020-09-28 23:26:06 +00:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- define "mysql.dns" -}}
|
2020-10-30 01:08:58 +08:00
|
|
|
{{- printf "%s-mysql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.mysql.service.port | trunc 63 | trimSuffix "-" -}}
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-09-28 23:26:06 +00:00
|
|
|
{{- define "mariadb.dns" -}}
|
2020-10-30 01:08:58 +08:00
|
|
|
{{- printf "%s-mariadb.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.mariadb.primary.service.port | trunc 63 | trimSuffix "-" -}}
|
2020-09-28 23:26:06 +00:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- define "memcached.dns" -}}
|
2020-10-30 01:08:58 +08:00
|
|
|
{{- printf "%s-memcached.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.memcached.service.port | trunc 63 | trimSuffix "-" -}}
|
2019-12-12 13:38:31 -05:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-08-23 17:56:55 +00:00
|
|
|
{{- define "gitea.default_domain" -}}
|
2020-10-30 01:08:58 +08:00
|
|
|
{{- printf "%s-gitea.%s.svc.%s" (include "gitea.fullname" .) .Release.Namespace .Values.clusterDomain | trunc 63 | trimSuffix "-" -}}
|
2019-12-12 13:38:31 -05:00
|
|
|
{{- end -}}
|
|
|
|
|
2020-12-16 20:37:47 +08:00
|
|
|
{{- define "gitea.ldap_settings" -}}
|
2021-10-08 20:16:24 +08:00
|
|
|
{{- $idx := index . 0 }}
|
|
|
|
{{- $values := index . 1 }}
|
|
|
|
|
|
|
|
{{- if not (hasKey $values "bindDn") -}}
|
|
|
|
{{- $_ := set $values "bindDn" "" -}}
|
2021-06-10 19:13:33 +08:00
|
|
|
{{- end -}}
|
|
|
|
|
2021-10-08 20:16:24 +08:00
|
|
|
{{- if not (hasKey $values "bindPassword") -}}
|
|
|
|
{{- $_ := set $values "bindPassword" "" -}}
|
2021-06-10 19:13:33 +08:00
|
|
|
{{- end -}}
|
|
|
|
|
2021-07-06 13:28:13 +08:00
|
|
|
{{- $flags := list "notActive" "skipTlsVerify" "allowDeactivateAll" "synchronizeUsers" "attributesInBind" -}}
|
2021-10-08 20:16:24 +08:00
|
|
|
{{- range $key, $val := $values -}}
|
2021-06-10 19:13:33 +08:00
|
|
|
{{- if and (ne $key "enabled") (ne $key "existingSecret") -}}
|
2021-07-06 13:28:13 +08:00
|
|
|
{{- if eq $key "bindDn" -}}
|
2021-10-08 20:16:24 +08:00
|
|
|
{{- printf "--%s \"${GITEA_LDAP_BIND_DN_%d}\" " ($key | kebabcase) ($idx) -}}
|
2021-07-06 13:28:13 +08:00
|
|
|
{{- else if eq $key "bindPassword" -}}
|
2021-10-08 20:16:24 +08:00
|
|
|
{{- printf "--%s \"${GITEA_LDAP_PASSWORD_%d}\" " ($key | kebabcase) ($idx) -}}
|
2021-06-10 19:13:33 +08:00
|
|
|
{{- else if eq $key "port" -}}
|
2021-07-06 13:28:13 +08:00
|
|
|
{{- printf "--%s %d " $key ($val | int) -}}
|
|
|
|
{{- else if has $key $flags -}}
|
2021-06-30 04:09:16 +08:00
|
|
|
{{- printf "--%s " ($key | kebabcase) -}}
|
2020-12-16 20:37:47 +08:00
|
|
|
{{- else -}}
|
2021-06-30 04:09:16 +08:00
|
|
|
{{- printf "--%s %s " ($key | kebabcase) ($val | squote) -}}
|
2020-12-16 20:37:47 +08:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2021-03-01 20:24:11 +08:00
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "gitea.oauth_settings" -}}
|
2021-12-20 22:43:55 +08:00
|
|
|
{{- $idx := index . 0 }}
|
|
|
|
{{- $values := index . 1 }}
|
|
|
|
|
|
|
|
{{- if not (hasKey $values "key") -}}
|
|
|
|
{{- $_ := set $values "key" (printf "${GITEA_OAUTH_KEY_%d}" $idx) -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if not (hasKey $values "secret") -}}
|
|
|
|
{{- $_ := set $values "secret" (printf "${GITEA_OAUTH_SECRET_%d}" $idx) -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- range $key, $val := $values -}}
|
2021-12-21 18:59:18 +08:00
|
|
|
{{- if ne $key "existingSecret" -}}
|
2021-12-20 22:43:55 +08:00
|
|
|
{{- printf "--%s %s " ($key | kebabcase) ($val | quote) -}}
|
2021-03-01 20:24:11 +08:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2021-04-29 17:12:48 +08:00
|
|
|
{{- end -}}
|
2021-12-22 18:44:04 +08:00
|
|
|
|
|
|
|
{{- define "gitea.inline_configuration" -}}
|
|
|
|
{{- include "gitea.inline_configuration.init" . -}}
|
|
|
|
{{- include "gitea.inline_configuration.defaults" . -}}
|
|
|
|
|
|
|
|
{{- $generals := list -}}
|
|
|
|
{{- $inlines := dict -}}
|
|
|
|
|
|
|
|
{{- range $key, $value := .Values.gitea.config }}
|
|
|
|
{{- if kindIs "map" $value }}
|
|
|
|
{{- if gt (len $value) 0 }}
|
|
|
|
{{- $section := default list (get $inlines $key) -}}
|
|
|
|
{{- range $n_key, $n_value := $value }}
|
|
|
|
{{- $section = append $section (printf "%s=%v" $n_key $n_value) -}}
|
|
|
|
{{- end }}
|
|
|
|
{{- $_ := set $inlines $key (join "\n" $section) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- else }}
|
|
|
|
{{- if or (eq $key "APP_NAME") (eq $key "RUN_USER") (eq $key "RUN_MODE") -}}
|
|
|
|
{{- $generals = append $generals (printf "%s=%s" $key $value) -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- (printf "Key %s cannot be on top level of configuration" $key) | fail -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- $_ := set $inlines "_generals_" (join "\n" $generals) -}}
|
|
|
|
{{- toYaml $inlines -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "gitea.inline_configuration.init" -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config "cache") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "cache" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config "server") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "server" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config "metrics") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "metrics" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config "database") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "database" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config "security") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "security" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not .Values.gitea.config.repository -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "repository" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config "oauth2") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config "oauth2" dict -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "gitea.inline_configuration.defaults" -}}
|
|
|
|
{{- include "gitea.inline_configuration.defaults.server" . -}}
|
|
|
|
{{- include "gitea.inline_configuration.defaults.database" . -}}
|
|
|
|
|
|
|
|
{{- if not .Values.gitea.config.repository.ROOT -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.repository "ROOT" "/data/git/gitea-repositories" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not .Values.gitea.config.security.INSTALL_LOCK -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.security "INSTALL_LOCK" "true" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config.metrics "ENABLED") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}}
|
|
|
|
{{- end -}}
|
2021-12-22 23:41:35 +08:00
|
|
|
{{- if .Values.memcached.enabled -}}
|
2021-12-22 18:44:04 +08:00
|
|
|
{{- $_ := set .Values.gitea.config.cache "ENABLED" "true" -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.cache "ADAPTER" "memcache" -}}
|
|
|
|
{{- if not (.Values.gitea.config.cache.HOST) -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.cache "HOST" (include "memcached.dns" .) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "gitea.inline_configuration.defaults.server" -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config.server "HTTP_PORT") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "HTTP_PORT" .Values.service.http.port -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not .Values.gitea.config.server.PROTOCOL -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "PROTOCOL" "http" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (.Values.gitea.config.server.DOMAIN) -}}
|
|
|
|
{{- if gt (len .Values.ingress.hosts) 0 -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "DOMAIN" (index .Values.ingress.hosts 0).host -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "DOMAIN" (include "gitea.default_domain" .) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not .Values.gitea.config.server.ROOT_URL -}}
|
|
|
|
{{- if .Values.ingress.enabled -}}
|
|
|
|
{{- if gt (len .Values.ingress.tls) 0 -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "ROOT_URL" (printf "%s://%s" .Values.gitea.config.server.PROTOCOL (index (index .Values.ingress.tls 0).hosts 0)) -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "ROOT_URL" (printf "%s://%s" .Values.gitea.config.server.PROTOCOL (index .Values.ingress.hosts 0).host) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "ROOT_URL" (printf "%s://%s" .Values.gitea.config.server.PROTOCOL .Values.gitea.config.server.DOMAIN) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not .Values.gitea.config.server.SSH_DOMAIN -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "SSH_DOMAIN" .Values.gitea.config.server.DOMAIN -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not .Values.gitea.config.server.SSH_PORT -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "SSH_PORT" .Values.service.ssh.port -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config.server "SSH_LISTEN_PORT") -}}
|
|
|
|
{{- if not .Values.image.rootless -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "SSH_LISTEN_PORT" .Values.gitea.config.server.SSH_PORT -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "SSH_LISTEN_PORT" "2222" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config.server "START_SSH_SERVER") -}}
|
|
|
|
{{- if .Values.image.rootless -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "START_SSH_SERVER" "true" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config.server "APP_DATA_PATH") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "APP_DATA_PATH" "/data" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if not (hasKey .Values.gitea.config.server "ENABLE_PPROF") -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.server "ENABLE_PPROF" false -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "gitea.inline_configuration.defaults.database" -}}
|
2021-12-22 23:41:35 +08:00
|
|
|
{{- if .Values.postgresql.enabled -}}
|
2021-12-22 18:44:04 +08:00
|
|
|
{{- $_ := set .Values.gitea.config.database "DB_TYPE" "postgres" -}}
|
|
|
|
{{- if not (.Values.gitea.config.database.HOST) -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "HOST" (include "postgresql.dns" .) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "NAME" .Values.postgresql.global.postgresql.postgresqlDatabase -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "USER" .Values.postgresql.global.postgresql.postgresqlUsername -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "PASSWD" .Values.postgresql.global.postgresql.postgresqlPassword -}}
|
2021-12-22 23:41:35 +08:00
|
|
|
{{- else if .Values.mysql.enabled -}}
|
2021-12-22 18:44:04 +08:00
|
|
|
{{- $_ := set .Values.gitea.config.database "DB_TYPE" "mysql" -}}
|
|
|
|
{{- if not (.Values.gitea.config.database.HOST) -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "HOST" (include "mysql.dns" .) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "NAME" .Values.mysql.db.name -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "USER" .Values.mysql.db.user -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "PASSWD" .Values.mysql.db.password -}}
|
2021-12-22 23:41:35 +08:00
|
|
|
{{- else if .Values.mariadb.enabled -}}
|
2021-12-22 18:44:04 +08:00
|
|
|
{{- $_ := set .Values.gitea.config.database "DB_TYPE" "mysql" -}}
|
|
|
|
{{- if not (.Values.gitea.config.database.HOST) -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "HOST" (include "mariadb.dns" .) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "NAME" .Values.mariadb.auth.database -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "USER" .Values.mariadb.auth.username -}}
|
|
|
|
{{- $_ := set .Values.gitea.config.database "PASSWD" .Values.mariadb.auth.password -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|