|
| 1 | +{{/* vim: set filetype=mustache: */}} |
| 2 | + |
| 3 | +{{/* |
| 4 | +Return the proper voltdb image name |
| 5 | +*/}} |
| 6 | +{{- define "voltdb.image" -}} |
| 7 | +{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }} |
| 8 | +{{- end -}} |
| 9 | + |
| 10 | +{{/* |
| 11 | +Create the name of the service account to use |
| 12 | +*/}} |
| 13 | +{{- define "voltdb.serviceAccountName" -}} |
| 14 | +{{- if .Values.serviceAccount.create -}} |
| 15 | + {{ default (include "common.names.fullname" .) .Values.serviceAccount.name }} |
| 16 | +{{- else -}} |
| 17 | + {{ default "default" .Values.serviceAccount.name }} |
| 18 | +{{- end -}} |
| 19 | +{{- end -}} |
| 20 | + |
| 21 | +{{/* |
| 22 | +Return the voltdb configuration configmap |
| 23 | +*/}} |
| 24 | +{{- define "voltdb.configmapName" -}} |
| 25 | +{{- printf "%s-configuration" (include "common.names.fullname" .) -}} |
| 26 | +{{- end -}} |
| 27 | + |
| 28 | +{{/* |
| 29 | +Return the proper Docker Image Registry Secret Names |
| 30 | +*/}} |
| 31 | +{{- define "voltdb.imagePullSecrets" -}} |
| 32 | +{{ include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) }} |
| 33 | +{{- end -}} |
| 34 | + |
| 35 | +{{/* |
| 36 | +Return the list of voltdb hosts |
| 37 | +*/}} |
| 38 | +{{- define "voltdb.hosts" -}} |
| 39 | +{{- $hosts := list }} |
| 40 | +{{- $fullname := include "common.names.fullname" . }} |
| 41 | +{{- $releaseNamespace := .Release.Namespace }} |
| 42 | +{{- $clusterDomain := .Values.clusterDomain }} |
| 43 | +{{- $hostCount := .Values.replicaCount | int }} |
| 44 | +{{- range $e, $i := until $hostCount }} |
| 45 | +{{- $hosts = append $hosts (printf "%s-%d.%s-headless.%s.svc.%s" $fullname $i $fullname $releaseNamespace $clusterDomain) }} |
| 46 | +{{- end }} |
| 47 | +{{- join "," $hosts }} |
| 48 | +{{- end -}} |
| 49 | + |
| 50 | +{{/* |
| 51 | +Return path to deployment.xml |
| 52 | +*/}} |
| 53 | +{{- define "voltdb.configPath" -}} |
| 54 | +{{- printf "%s/deployment.xml" .Values.voltdb.directorySpec -}} |
| 55 | +{{- end -}} |
| 56 | + |
| 57 | +{{/* |
| 58 | +Return path to license.xml |
| 59 | +*/}} |
| 60 | +{{- define "voltdb.licensePath" -}} |
| 61 | +{{- printf "%s/license.xml" .Values.voltdb.directorySpec -}} |
| 62 | +{{- end -}} |
| 63 | + |
| 64 | +{{/* |
| 65 | +Return path to voltdbroot |
| 66 | +*/}} |
| 67 | +{{- define "voltdb.rootPath" -}} |
| 68 | +{{- printf "%s/voltdbroot" .Values.voltdb.directorySpec -}} |
| 69 | +{{- end -}} |
| 70 | + |
| 71 | +{{/* |
| 72 | +Return terminal paths in a dictionary |
| 73 | +Usage: {{ include "util.terminalPaths" dict }} |
| 74 | +*/}} |
| 75 | +{{- define "util.terminalPaths" -}} |
| 76 | +{{- $terminalPaths := list }} |
| 77 | +{{- range $k, $v := . }} |
| 78 | + {{- if not (or (kindIs "map" $v) (kindIs "slice" $v)) -}} |
| 79 | + {{- $terminalPaths = append $terminalPaths (printf "%s=\"%v\"" $k $v) }} |
| 80 | + {{- end }} |
| 81 | +{{- end }} |
| 82 | +{{- join " " $terminalPaths }} |
| 83 | +{{- end -}} |
| 84 | + |
| 85 | +{{/* |
| 86 | +Return if a dictionary is nested |
| 87 | +Usage: {{ include "util.isNested" dict }} |
| 88 | +*/}} |
| 89 | +{{- define "util.isNested" -}} |
| 90 | +{{- $isNested := false -}} |
| 91 | +{{- range $k, $v := . }} |
| 92 | + {{- if or (kindIs "map" $v) (kindIs "slice" $v) -}} |
| 93 | + {{- $isNested = true -}} |
| 94 | + {{- end }} |
| 95 | +{{- end }} |
| 96 | +{{- $isNested }} |
| 97 | +{{- end -}} |
| 98 | + |
| 99 | +{{/* |
| 100 | +Return voltdb configuration |
| 101 | +*/}} |
| 102 | +{{- define "voltdb.configuration" -}} |
| 103 | + {{- $currentIndentation:= ($.indentation | default "") -}} |
| 104 | + {{- range $k, $v := .object }} |
| 105 | + {{- if or (eq "import" $k) (eq "export" $k) -}} |
| 106 | + {{- else if kindIs "map" $v -}} |
| 107 | + |
| 108 | + {{- if eq "false" (include "util.isNested" $v) -}} |
| 109 | + {{- printf "%s<%s %s/>\n" $currentIndentation $k (include "util.terminalPaths" $v ) }} |
| 110 | + {{- else -}} |
| 111 | + {{- printf "%s<%s %s>\n" $currentIndentation $k (include "util.terminalPaths" $v ) }} |
| 112 | + {{- printf "%s" (include "voltdb.configuration" (dict "object" $v "indentation" (printf "%s " $currentIndentation))) }} |
| 113 | + {{- printf "%s</%s>\n" $currentIndentation $k -}} |
| 114 | + {{- end -}} |
| 115 | + {{- else if kindIs "slice" $v -}} |
| 116 | + {{- range $dict := $v }} |
| 117 | + {{- printf "%s" (include "voltdb.configuration" (dict "object" (dict $k $dict) "indentation" (printf "%s" $currentIndentation))) }} |
| 118 | + {{- end }} |
| 119 | + {{- else -}} |
| 120 | + {{- end -}} |
| 121 | + {{- end }} |
| 122 | +{{- end -}} |
| 123 | + |
| 124 | + |
0 commit comments