feat: add template common.container
This commit is contained in:
15
templates/_container.yaml
Normal file
15
templates/_container.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{- define "common.container.tpl" -}}
|
||||||
|
name: {{ .Chart.Name }}
|
||||||
|
securityContext:
|
||||||
|
{{- toYaml .Values.securityContext | nindent 4 }}
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
resources:
|
||||||
|
{{- toYaml .Values.resources | nindent 4 }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "common.container" -}}
|
||||||
|
{{- include "common.utils.flattenCall" (list "common.utils.merge" . "common.container.tpl") -}}
|
||||||
|
{{- end -}}
|
34
templates/_utils.tpl
Normal file
34
templates/_utils.tpl
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{- /*
|
||||||
|
Merge one or more YAML templates and output the result.
|
||||||
|
This takes an list of values:
|
||||||
|
- the first item is the top context
|
||||||
|
- the rest items are template names of the templates, the former one will override the latter.
|
||||||
|
*/ -}}
|
||||||
|
{{- define "common.utils.merge" -}}
|
||||||
|
{{- $top := first . -}}
|
||||||
|
{{- $dest := dict -}}
|
||||||
|
{{- range (rest .) -}}
|
||||||
|
{{- $src := fromYaml (include . $top) | default (dict) -}}
|
||||||
|
{{- $dest = merge $dest $src -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- toYaml $dest -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- /*
|
||||||
|
Flatten list of arguments before rendering the given template.
|
||||||
|
This takes an list of values:
|
||||||
|
- the first item is the template name to be rendered
|
||||||
|
- the second item is either an list of arguments or a single argument
|
||||||
|
- the rest items are the appended arguments
|
||||||
|
*/ -}}
|
||||||
|
{{- define "common.utils.flattenCall" -}}
|
||||||
|
{{- $tpl := first . -}}
|
||||||
|
{{- $args := index . 1 -}}
|
||||||
|
{{- if not (typeIs "[]interface {}" $args) -}}
|
||||||
|
{{- $args = list $args -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $args = concat $args (slice . 2) -}}
|
||||||
|
{{- include $tpl $args -}}
|
||||||
|
{{- end -}}
|
Reference in New Issue
Block a user