-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_high_availability.tpl
39 lines (34 loc) · 1.79 KB
/
_high_availability.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{{- /* Usage: {{ include "helm_lib_is_ha_to_value" (list . yes no) }} */ -}}
{{- /* returns value "yes" if cluster is highly available, else — returns "no" */ -}}
{{- define "helm_lib_is_ha_to_value" }}
{{- $context := index . 0 -}} {{- /* Template context with .Values, .Chart, etc */ -}}
{{- $yes := index . 1 -}} {{- /* Yes value */ -}}
{{- $no := index . 2 -}} {{- /* No value */ -}}
{{- $module_values := (index $context.Values (include "helm_lib_module_camelcase_name" $context)) }}
{{- if hasKey $module_values "highAvailability" -}}
{{- if $module_values.highAvailability -}} {{- $yes -}} {{- else -}} {{- $no -}} {{- end -}}
{{- else if hasKey $context.Values.global "highAvailability" -}}
{{- if $context.Values.global.highAvailability -}} {{- $yes -}} {{- else -}} {{- $no -}} {{- end -}}
{{- else -}}
{{- if $context.Values.global.discovery.clusterControlPlaneIsHighlyAvailable -}} {{- $yes -}} {{- else -}} {{- $no -}} {{- end -}}
{{- end -}}
{{- end }}
{{- /* Usage: {{- if (include "helm_lib_ha_enabled" .) }} */ -}}
{{- /* returns empty value, which is treated by go template as false */ -}}
{{- define "helm_lib_ha_enabled" }}
{{- $context := . -}} {{- /* Template context with .Values, .Chart, etc */ -}}
{{- $module_values := (index $context.Values (include "helm_lib_module_camelcase_name" $context)) }}
{{- if hasKey $module_values "highAvailability" -}}
{{- if $module_values.highAvailability -}}
"not empty string"
{{- end -}}
{{- else if hasKey $context.Values.global "highAvailability" -}}
{{- if $context.Values.global.highAvailability -}}
"not empty string"
{{- end -}}
{{- else -}}
{{- if $context.Values.global.discovery.clusterControlPlaneIsHighlyAvailable -}}
"not empty string"
{{- end -}}
{{- end -}}
{{- end -}}