mirror of
https://github.com/truenas/charts.git
synced 2026-04-24 10:30:37 +08:00
* Adapt charts CI and improve/fix common * add check on permissions contaienr * add postgres template * update comments * Update create_app.sh * add check * update script * auto gen item.yaml from Chart,yaml * rename readme on dest * duplicate readme from the same source * correct comment * reoder * remove extra space * keep both README and app-readme * update regex, to also allow 2 letter names, which is also valid * No need to check host network if there aren't any pod values * use same pattern as the pod.name label (not prepending release-name * update deps * add chart dirs to ci * Add a validation to check if there is any yaml errors after merging files * update charts path on ci * common/1.0.0/ -> common/ * update common-test dep path * temp update create_app script * make permissions container name configurable, incase we want to change order of execution * update naming convention * fix typo and a missed name change * do not allow `--` in names
85 lines
3.1 KiB
Smarty
85 lines
3.1 KiB
Smarty
{{/* Returns Env */}}
|
|
{{/* Call this template:
|
|
{{ include "ix.v1.common.lib.container.env" (dict "rootCtx" $ "objectData" $objectData) }}
|
|
rootCtx: The root context of the chart.
|
|
objectData: The object data to be used to render the container.
|
|
*/}}
|
|
{{- define "ix.v1.common.lib.container.env" -}}
|
|
{{- $rootCtx := .rootCtx -}}
|
|
{{- $objectData := .objectData -}}
|
|
|
|
{{- range $k, $v := $objectData.env -}}
|
|
{{- include "ix.v1.common.helper.container.envDupeCheck" (dict "rootCtx" $rootCtx "objectData" $objectData "source" "env" "key" $k) }}
|
|
- name: {{ $k | quote }}
|
|
{{- if not (kindIs "map" $v) }}
|
|
value: {{ tpl (toString $v) $rootCtx | quote }}
|
|
{{- else if kindIs "map" $v }}
|
|
valueFrom:
|
|
{{- $refs := (list "configMapKeyRef" "secretKeyRef" "fieldRef") -}}
|
|
{{- if or (ne (len ($v | keys)) 1) (not (mustHas ($v | keys | first) $refs)) -}}
|
|
{{- fail (printf "Container - Expected <env> with a ref to have one of [%s], but got [%s]" (join ", " $refs) (join ", " ($v | keys | sortAlpha))) -}}
|
|
{{- end -}}
|
|
|
|
{{- $expandName := true -}}
|
|
{{- $name := "" -}}
|
|
|
|
{{- range $key := (list "configMapKeyRef" "secretKeyRef") -}}
|
|
{{- if hasKey $v $key }}
|
|
{{ $key }}:
|
|
{{- $obj := get $v $key -}}
|
|
{{- if not $obj.name -}}
|
|
{{- fail (printf "Container - Expected non-empty <env.%s.name>" $key) -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $obj.key -}}
|
|
{{- fail (printf "Container - Expected non-empty <env.%s.key>" $key) -}}
|
|
{{- end }}
|
|
key: {{ $obj.key | quote }}
|
|
|
|
{{- $name = tpl $obj.name $rootCtx -}}
|
|
{{- if kindIs "bool" $obj.expandObjectName -}}
|
|
{{- $expandName = $obj.expandObjectName -}}
|
|
{{- end -}}
|
|
|
|
{{- if $expandName -}}
|
|
{{- $item := ($key | trimSuffix "KeyRef" | lower) -}}
|
|
|
|
{{- $data := (get $rootCtx.Values $item) -}}
|
|
{{- $data = (get $data $name) -}}
|
|
|
|
{{- if not $data -}}
|
|
{{- fail (printf "Container - Expected in <env> the referenced %s [%s] to be defined" (camelcase $item) $name) -}}
|
|
{{- end -}}
|
|
|
|
{{- $found := false -}}
|
|
{{- range $k, $v := $data.data -}}
|
|
{{- if eq $k $obj.key -}}
|
|
{{- $found = true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $found -}}
|
|
{{- fail (printf "Container - Expected in <env> the referenced key [%s] in %s [%s] to be defined" $obj.key (camelcase $item) $name) -}}
|
|
{{- end -}}
|
|
|
|
{{- $name = (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $rootCtx) $name) -}}
|
|
{{- end }}
|
|
name: {{ $name | quote }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if hasKey $v "fieldRef" }}
|
|
fieldRef:
|
|
{{- if not $v.fieldRef.fieldPath -}}
|
|
{{- fail "Container - Expected non-empty <env.fieldRef.fieldPath>" -}}
|
|
{{- end }}
|
|
fieldPath: {{ $v.fieldRef.fieldPath | quote }}
|
|
{{- if $v.fieldRef.apiVersion }}
|
|
apiVersion: {{ $v.fieldRef.apiVersion | quote }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
{{- end -}}
|