diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 2d12b81..608cfcc 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -35,10 +35,40 @@ Create chart name and version as used by the chart label. Create image name and tag used by the deployment. */}} {{- define "gitea.image" -}} +{{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}} {{- $name := .Values.image.repository -}} {{- $tag := .Values.image.tag | default .Chart.AppVersion -}} {{- $rootless := ternary "-rootless" "" (.Values.image.rootless) -}} -{{- printf "%s:%s%s" $name $tag $rootless -}} +{{- 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 }} {{- end -}} {{/* diff --git a/templates/gitea/statefulset.yaml b/templates/gitea/statefulset.yaml index 7dbe417..9618d84 100644 --- a/templates/gitea/statefulset.yaml +++ b/templates/gitea/statefulset.yaml @@ -39,10 +39,7 @@ spec: {{- if .Values.schedulerName }} schedulerName: "{{ .Values.schedulerName }}" {{- end }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} + {{- include "gitea.images.pullSecrets" . | nindent 6 }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} initContainers: @@ -342,9 +339,7 @@ spec: {{- range .Values.persistence.accessModes }} - {{ . | quote }} {{- end }} - {{- if .Values.persistence.storageClass }} - storageClassName: {{ .Values.persistence.storageClass | quote }} - {{- end }} + {{- include "gitea.persistence.storageClass" . | indent 8 }} resources: requests: storage: {{ .Values.persistence.size | quote }} diff --git a/values.yaml b/values.yaml index b6e6fbc..5c86cd4 100644 --- a/values.yaml +++ b/values.yaml @@ -1,6 +1,14 @@ # Default values for gitea. # This is a YAML-formatted file. # Declare variables to be passed into your templates. +global: + imageRegistry: "" + ## E.g. + ## imagePullSecrets: + ## - myRegistryKeySecretName + ## + imagePullSecrets: [] + storageClass: "" replicaCount: 1