111 lines
2.7 KiB
Smarty
111 lines
2.7 KiB
Smarty
{{/*
|
|
Expand the name of the chart.
|
|
*/}}
|
|
{{- define "nats.name" -}}
|
|
{{- default .Chart.Name .Values.nats.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
|
|
{{- define "nats.fullname" -}}
|
|
{{- if .Values.nats.fullnameOverride -}}
|
|
{{- .Values.nats.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- $name := default .Chart.Name .Values.nats.nameOverride -}}
|
|
{{- if contains $name .Release.Name -}}
|
|
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "nats.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Common labels
|
|
*/}}
|
|
{{- define "nats.labels" -}}
|
|
app.kubernetes.io/name: nats
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
helm.sh/chart: {{ include "nats.chart" . }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Selector labels
|
|
*/}}
|
|
{{- define "nats.selectorLabels" -}}
|
|
app.kubernetes.io/name: nats
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{/*
|
|
Return the proper NATS image name
|
|
*/}}
|
|
{{- define "nats.clusterAdvertise" -}}
|
|
{{- printf "$(POD_NAME).%s.$(POD_NAMESPACE).svc.%s" (include "nats.fullname" . ) $.Values.nats.k8sClusterDomain }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Return the NATS cluster routes.
|
|
*/}}
|
|
{{- define "nats.clusterRoutes" -}}
|
|
{{- $name := (include "nats.fullname" . ) -}}
|
|
{{- range $i, $e := until (.Values.nats.cluster.replicas | int) -}}
|
|
{{- printf "nats://%s-%d.%s.%s.svc.%s:6222," $name $i $name $.Release.Namespace $.Values.nats.k8sClusterDomain -}}
|
|
{{- end -}}
|
|
{{- end }}
|
|
|
|
{{- define "nats.extraRoutes" -}}
|
|
{{- range $i, $url := .Values.nats.cluster.extraRoutes -}}
|
|
{{- printf "%s," $url -}}
|
|
{{- end -}}
|
|
{{- end }}
|
|
|
|
{{- define "nats.tlsConfig" -}}
|
|
tls {
|
|
{{- if .cert }}
|
|
cert_file: {{ .secretPath }}/{{ .secret.name }}/{{ .cert }}
|
|
{{- end }}
|
|
{{- if .key }}
|
|
key_file: {{ .secretPath }}/{{ .secret.name }}/{{ .key }}
|
|
{{- end }}
|
|
{{- if .ca }}
|
|
ca_file: {{ .secretPath }}/{{ .secret.name }}/{{ .ca }}
|
|
{{- end }}
|
|
{{- if .insecure }}
|
|
insecure: {{ .insecure }}
|
|
{{- end }}
|
|
{{- if .verify }}
|
|
verify: {{ .verify }}
|
|
{{- end }}
|
|
{{- if .verifyAndMap }}
|
|
verify_and_map: {{ .verifyAndMap }}
|
|
{{- end }}
|
|
{{- if .curvePreferences }}
|
|
curve_preferences: {{ .curvePreferences }}
|
|
{{- end }}
|
|
{{- if .timeout }}
|
|
timeout: {{ .timeout }}
|
|
{{- end }}
|
|
}
|
|
{{- end }}
|
|
|
|
|
|
{{/*
|
|
Renders a value that contains template.
|
|
Usage:
|
|
{{ include "tplvalues.render" ( dict "value" .Values.nats.path.to.the.Value "context" $) }}
|
|
*/}}
|
|
{{- define "tplvalues.render" -}}
|
|
{{- if typeIs "string" .value }}
|
|
{{- tpl .value .context }}
|
|
{{- else }}
|
|
{{- tpl (.value | toYaml) .context }}
|
|
{{- end }}
|
|
{{- end -}}
|