Merge branch 'sliding-sync-init' into 'master'
sliding-sync-proxy: Add support for init containers. See merge request ananace/charts!52
This commit is contained in:
commit
7e1fb29a5f
3 changed files with 70 additions and 0 deletions
|
@ -28,6 +28,24 @@ spec:
|
|||
{{- end }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
{{- if .Values.initContainers }}
|
||||
initContainers:
|
||||
{{- $initContainers := list }}
|
||||
{{- range $index, $key := (keys .Values.initContainers | uniq | sortAlpha) }}
|
||||
{{- $container := get $.Values.initContainers $key }}
|
||||
{{- if not $container.name -}}
|
||||
{{- $_ := set $container "name" $key }}
|
||||
{{- end }}
|
||||
{{- if $container.env -}}
|
||||
{{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}}
|
||||
{{- $newEnv := fromYaml (include "lib.container.envVars" $) -}}
|
||||
{{- $_ := unset $.ObjectValues "envVars" -}}
|
||||
{{- $_ := set $container "env" $newEnv.env }}
|
||||
{{- end }}
|
||||
{{- $initContainers = append $initContainers $container }}
|
||||
{{- end }}
|
||||
{{- tpl (toYaml $initContainers) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
securityContext:
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{{/*
|
||||
Environment variables used by containers.
|
||||
*/}}
|
||||
{{- define "lib.container.envVars" -}}
|
||||
{{- $values := .Values.env -}}
|
||||
{{- if hasKey . "ObjectValues" -}}
|
||||
{{- with .ObjectValues.envVars -}}
|
||||
{{- $values = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $values -}}
|
||||
{{- $result := list -}}
|
||||
{{- range $k, $v := . -}}
|
||||
{{- $name := $k -}}
|
||||
{{- $value := $v -}}
|
||||
{{- if kindIs "int" $name -}}
|
||||
{{- $name = required "environment variables as a list of maps require a name field" $value.name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "map" $value -}}
|
||||
{{- if hasKey $value "value" -}}
|
||||
{{- $envValue := $value.value | toString -}}
|
||||
{{- $result = append $result (dict "name" $name "value" (tpl $envValue $)) -}}
|
||||
{{- else if hasKey $value "valueFrom" -}}
|
||||
{{- $result = append $result (dict "name" $name "valueFrom" $value.valueFrom) -}}
|
||||
{{- else -}}
|
||||
{{- $result = append $result (dict "name" $name "valueFrom" $value) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if not (kindIs "map" $value) -}}
|
||||
{{- if kindIs "string" $value -}}
|
||||
{{- $result = append $result (dict "name" $name "value" (tpl $value $)) -}}
|
||||
{{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}}
|
||||
{{- $result = append $result (dict "name" $name "value" ($value | toString)) -}}
|
||||
{{- else -}}
|
||||
{{- $result = append $result (dict "name" $name "value" $value) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- toYaml (dict "env" $result) | nindent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -17,6 +17,15 @@ extraEnv: {}
|
|||
# SYNCV3_DEBUG: "true"
|
||||
|
||||
imagePullSecrets: []
|
||||
#initContainers:
|
||||
# 01-init-db:
|
||||
# image: ghcr.io/onedr0p/postgres-init:14.9
|
||||
# imagePullPolicy: IfNotPresent
|
||||
# envFrom: &envFrom
|
||||
# - configMapRef:
|
||||
# name: &configMap synapse-configmap
|
||||
# - secretRef:
|
||||
# name: &secret synapse-secret
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue