style: remove most right whitespace chomps except those directly following a template definition
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.configMap.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $top := first . }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
{{- include "common.metadata" (list $top) | nindent 2 }}
|
||||
data: {}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.configMap" -}}
|
||||
{{- include "common.utils.merge" (append . "common.configMap.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.configMap.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.container.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $container := index . 1 -}}
|
||||
{{- $image := $container.image | default (dict) -}}
|
||||
{{- $top := first . }}
|
||||
{{- $container := index . 1 }}
|
||||
{{- $image := $container.image | default (dict) }}
|
||||
name: {{ $top.Chart.Name }}
|
||||
securityContext:
|
||||
{{- toYaml $container.securityContext | nindent 2 }}
|
||||
@ -11,8 +11,8 @@ image: "{{ $image.repository }}:{{ $image.tag | default $top.Chart.AppVersion }}
|
||||
imagePullPolicy: {{ $container.image.pullPolicy }}
|
||||
resources:
|
||||
{{- toYaml $container.resources | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.container" -}}
|
||||
{{- include "common.utils.merge" (append . "common.container.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.container.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -3,13 +3,13 @@
|
||||
{{- define "common.cronJob.pod" -}}
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.cronJob.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $cronJob := index . 1 -}}
|
||||
{{- $pod := index . 2 -}}
|
||||
{{- $serviceAccount := index . 3 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $cronJob := index . 1 }}
|
||||
{{- $pod := index . 2 }}
|
||||
{{- $serviceAccount := index . 3 }}
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
@ -32,8 +32,8 @@ spec:
|
||||
spec:
|
||||
template:
|
||||
{{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.cronJob" -}}
|
||||
{{- include "common.utils.merge" (append . "common.cronJob.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.cronJob.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -1,10 +1,10 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.deployment.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $deployment := index . 1 -}}
|
||||
{{- $autoscaling := index . 2 -}}
|
||||
{{- $serviceAccount := index . 3 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $deployment := index . 1 }}
|
||||
{{- $autoscaling := index . 2 }}
|
||||
{{- $serviceAccount := index . 3 }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@ -18,8 +18,8 @@ spec:
|
||||
{{- include "common.selectorLabels" $top | nindent 6 }}
|
||||
template:
|
||||
{{- include "common.pod.template" (list $top $deployment $serviceAccount) | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.deployment" -}}
|
||||
{{- include "common.utils.merge" (append . "common.deployment.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.deployment.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -1,8 +1,8 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.hpa.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $autoscaling := index . 1 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $autoscaling := index . 1 }}
|
||||
apiVersion: autoscaling/v2beta2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
@ -30,12 +30,12 @@ spec:
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.hpa" -}}
|
||||
{{- $autoscaling := index . 1 -}}
|
||||
{{- if $autoscaling.enabled -}}
|
||||
{{- include "common.utils.merge" (append . "common.hpa.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $autoscaling := index . 1 }}
|
||||
{{- if $autoscaling.enabled }}
|
||||
{{- include "common.utils.merge" (append . "common.hpa.tpl") }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -1,22 +1,22 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.ingress.metadata" -}}
|
||||
{{- $ingress := index . 1 -}}
|
||||
{{- $ingress := index . 1 }}
|
||||
{{- with $ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.ingress.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $ingress := index . 1 -}}
|
||||
{{- $service := index . 2 -}}
|
||||
{{- $fullName := include "common.fullname" $top -}}
|
||||
{{- $svcPort := $service.port -}}
|
||||
{{- if semverCompare ">=1.14-0" $top.Capabilities.KubeVersion.GitVersion -}}
|
||||
{{- $top := first . }}
|
||||
{{- $ingress := index . 1 }}
|
||||
{{- $service := index . 2 }}
|
||||
{{- $fullName := include "common.fullname" $top }}
|
||||
{{- $svcPort := $service.port }}
|
||||
{{- if semverCompare ">=1.14-0" $top.Capabilities.KubeVersion.GitVersion }}
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
{{- else -}}
|
||||
{{- else }}
|
||||
apiVersion: extensions/v1beta1
|
||||
{{- end }}
|
||||
kind: Ingress
|
||||
@ -45,11 +45,11 @@ spec:
|
||||
servicePort: {{ $svcPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.ingress" -}}
|
||||
{{- $ingress := index . 1 -}}
|
||||
{{- if $ingress.enabled -}}
|
||||
{{- include "common.utils.merge" (append . "common.ingress.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $ingress := index . 1 }}
|
||||
{{- if $ingress.enabled }}
|
||||
{{- include "common.utils.merge" (append . "common.ingress.tpl") }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -10,7 +10,7 @@ helm.sh/chart: {{ include "common.chart" . }}
|
||||
app.kubernetes.io/version: {{ . | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
@ -18,18 +18,18 @@ Selector labels
|
||||
{{- define "common.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "common.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.metadata.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
name: {{ include "common.fullname" $top }}
|
||||
labels:
|
||||
{{- include "common.labels" $top | nindent 2 -}}
|
||||
{{- end -}}
|
||||
{{- include "common.labels" $top | nindent 2 }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
{{/*
|
||||
Create a standard metadata header
|
||||
*/ -}}
|
||||
*/}}
|
||||
{{- define "common.metadata" -}}
|
||||
{{- include "common.utils.merge" (append . "common.metadata.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.metadata.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -4,8 +4,8 @@
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "common.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
@ -13,34 +13,34 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "common.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- 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 "common.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use.
|
||||
*/}}
|
||||
{{- define "common.serviceAccountName" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceAccount := index . 1 -}}
|
||||
{{- if $serviceAccount.create -}}
|
||||
{{ default (include "common.fullname" $top) $serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" $serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceAccount := index . 1 }}
|
||||
{{- if $serviceAccount.create }}
|
||||
{{- default (include "common.fullname" $top) $serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" $serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -1,8 +1,8 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.pdb.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $pdb := index . 1 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $pdb := index . 1 }}
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
@ -11,22 +11,22 @@ spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "common.selectorLabels" $top | nindent 6 }}
|
||||
{{- if not (or (empty $pdb.minAvailable) (empty $pdb.maxUnavailable)) -}}
|
||||
{{- if not (or (empty $pdb.minAvailable) (empty $pdb.maxUnavailable)) }}
|
||||
{{- fail "minAvailable and maxUnavailable can not be set together" }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{- with $pdb.minAvailable }}
|
||||
minAvailable: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $pdb.maxUnavailable }}
|
||||
maxUnavailable: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.pdb" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $deployment := index . 2 -}}
|
||||
{{- $autoscaling := index . 3 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $deployment := index . 2 }}
|
||||
{{- $autoscaling := index . 3 }}
|
||||
{{- if or (and $autoscaling.enabled (gt ($autoscaling.minReplicas | int) 1)) (and (not $autoscaling.enabled) (gt ($deployment.replicaCount | int) 1)) }}
|
||||
{{- include "common.utils.merge" (append . "common.pdb.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.pdb.tpl") }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.pod.template.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $pod := index . 1 -}}
|
||||
{{- $serviceAccount := index . 2 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $pod := index . 1 }}
|
||||
{{- $serviceAccount := index . 2 }}
|
||||
metadata:
|
||||
{{- with $pod.podAnnotations }}
|
||||
annotations:
|
||||
@ -33,8 +33,8 @@ spec:
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.pod.template" -}}
|
||||
{{- include "common.utils.merge" (append . "common.pod.template.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.pod.template.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -1,15 +1,15 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.secret.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $top := first . }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
{{- include "common.metadata" (list $top) | nindent 2 }}
|
||||
type: Opaque
|
||||
data: {}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.secret" -}}
|
||||
{{- include "common.utils.merge" (append . "common.secret.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.secret.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -1,8 +1,8 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.service.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $service := index . 1 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $service := index . 1 }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@ -16,8 +16,8 @@ spec:
|
||||
name: http
|
||||
selector:
|
||||
{{- include "common.selectorLabels" $top | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.service" -}}
|
||||
{{- include "common.utils.merge" (append . "common.service.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- include "common.utils.merge" (append . "common.service.tpl") }}
|
||||
{{- end }}
|
||||
|
@ -1,26 +1,26 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.serviceAccount.metadata" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceAccount := index . 1 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceAccount := index . 1 }}
|
||||
name: {{ include "common.serviceAccountName" . }}
|
||||
{{- with $serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.serviceAccount.tpl" -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
{{- include "common.metadata" (append . "common.serviceAccount.metadata") | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.serviceAccount" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceAccount := index . 1 -}}
|
||||
{{- if $serviceAccount.create -}}
|
||||
{{- include "common.utils.merge" (append . "common.serviceAccount.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceAccount := index . 1 }}
|
||||
{{- if $serviceAccount.create }}
|
||||
{{- include "common.utils.merge" (append . "common.serviceAccount.tpl") }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.serviceMonitor.secret.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceMonitor := index . 1 -}}
|
||||
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceMonitor := index . 1 }}
|
||||
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) }}
|
||||
metadata:
|
||||
name: {{ $basicAuth.secretName | default (include "common.fullname" $top) }}
|
||||
{{- with $serviceMonitor.namespace }}
|
||||
@ -14,12 +14,12 @@ data:
|
||||
{{ $basicAuth.usernameKey | default "username" }}: {{ $basicAuth.username | toString | b64enc | quote }}
|
||||
{{ $basicAuth.passwordKey | default "password" }}: {{ $basicAuth.password | toString | b64enc | quote }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.serviceMonitor.secret" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceMonitor := index . 1 -}}
|
||||
{{- if $serviceMonitor.enabled -}}
|
||||
{{- include "common.secret" (append . "common.serviceMonitor.secret.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceMonitor := index . 1 }}
|
||||
{{- if $serviceMonitor.enabled }}
|
||||
{{- include "common.secret" (append . "common.serviceMonitor.secret.tpl") }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -1,15 +1,15 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- define "common.serviceMonitor.metadata" -}}
|
||||
{{- $serviceMonitor := index . 1 -}}
|
||||
{{- $serviceMonitor := index . 1 }}
|
||||
{{- with $serviceMonitor.namespace }}
|
||||
namespace: {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.serviceMonitor.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceMonitor := index . 1 -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceMonitor := index . 1 }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
@ -32,8 +32,8 @@ spec:
|
||||
{{- with $serviceMonitor.scrapeTimeout }}
|
||||
scrapeTimeout: {{ . }}
|
||||
{{- end }}
|
||||
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) -}}
|
||||
{{- $name := $basicAuth.secretName | default (include "common.fullname" $top) -}}
|
||||
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) }}
|
||||
{{- $name := $basicAuth.secretName | default (include "common.fullname" $top) }}
|
||||
{{- if $basicAuth.enabled }}
|
||||
basicAuth:
|
||||
username:
|
||||
@ -43,12 +43,12 @@ spec:
|
||||
name: {{ $name }}
|
||||
key: {{ $basicAuth.passwordKey | default "password" }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "common.serviceMonitor" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceMonitor := index . 1 -}}
|
||||
{{- if $serviceMonitor.enabled -}}
|
||||
{{- include "common.utils.merge" (append . "common.serviceMonitor.tpl") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $top := first . }}
|
||||
{{- $serviceMonitor := index . 1 }}
|
||||
{{- if $serviceMonitor.enabled }}
|
||||
{{- include "common.utils.merge" (append . "common.serviceMonitor.tpl") }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -1,24 +1,24 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{- /*
|
||||
{{/*
|
||||
Merge one or more YAML templates and output the result.
|
||||
This takes an list of values:
|
||||
- the top context
|
||||
- [optional] zero or more template args
|
||||
- [optional] the template name of the overrides (destination)
|
||||
- the template name of the base (source)
|
||||
*/ -}}
|
||||
*/}}
|
||||
{{- define "common.utils.merge" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $tplName := last . -}}
|
||||
{{- $args := initial . -}}
|
||||
{{- if typeIs "string" (last $args) -}}
|
||||
{{- $overridesName := last $args -}}
|
||||
{{- $args = initial $args -}}
|
||||
{{- $tpl := fromYaml (include $tplName $args) | default (dict) -}}
|
||||
{{- $overrides := fromYaml (include $overridesName $args) | default (dict) -}}
|
||||
{{- toYaml (merge $overrides $tpl) -}}
|
||||
{{- else -}}
|
||||
{{- include $tplName $args -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $top := first . }}
|
||||
{{- $tplName := last . }}
|
||||
{{- $args := initial . }}
|
||||
{{- if typeIs "string" (last $args) }}
|
||||
{{- $overridesName := last $args }}
|
||||
{{- $args = initial $args }}
|
||||
{{- $tpl := fromYaml (include $tplName $args) | default (dict) }}
|
||||
{{- $overrides := fromYaml (include $overridesName $args) | default (dict) }}
|
||||
{{- toYaml (merge $overrides $tpl) }}
|
||||
{{- else }}
|
||||
{{- include $tplName $args }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
Reference in New Issue
Block a user