|
| 1 | +{{/* vim: set filetype=mustache: */}} |
| 2 | +{{/* |
| 3 | +Expand the name of the chart. |
| 4 | +*/}} |
| 5 | +{{- define "dgraph.name" -}} |
| 6 | +{{- default .Chart.Name .Values.nameOverride | trunc 24 -}} |
| 7 | +{{- end -}} |
| 8 | +{{/* |
| 9 | +Create a default fully qualified app name. |
| 10 | +We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 11 | +*/}} |
| 12 | +{{- define "dgraph.fullname" -}} |
| 13 | +{{- if .Values.fullnameOverride -}} |
| 14 | +{{- .Values.fullnameOverride | trunc 24 | trimSuffix "-" -}} |
| 15 | +{{- else -}} |
| 16 | +{{- $name := default .Chart.Name .Values.nameOverride -}} |
| 17 | +{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} |
| 18 | +{{- end -}} |
| 19 | +{{- end -}} |
| 20 | +{{/* |
| 21 | +Create chart name and version as used by the chart label. |
| 22 | +*/}} |
| 23 | +{{- define "dgraph.chart" -}} |
| 24 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} |
| 25 | +{{- end -}} |
| 26 | + |
| 27 | +{{/* |
| 28 | +Create a default fully qualified data name. |
| 29 | +*/}} |
| 30 | +{{- define "dgraph.zero.fullname" -}} |
| 31 | +{{ template "dgraph.fullname" . }}-{{ .Values.zero.name }} |
| 32 | +{{- end -}} |
| 33 | + |
| 34 | +{{/* |
| 35 | +Create a default fully qualified data name. |
| 36 | +*/}} |
| 37 | +{{- define "dgraph.backups.fullname" -}} |
| 38 | +{{ template "dgraph.fullname" . }}-{{ .Values.backups.name }} |
| 39 | +{{- end -}} |
| 40 | + |
| 41 | +{{/* |
| 42 | +Create a semVer/calVer version from image.tag so that it can be safely use in |
| 43 | +version comparisions used to toggle features or behavior. |
| 44 | +*/}} |
| 45 | +{{- define "dgraph.version" -}} |
| 46 | +{{- $safeVersion := .Values.image.tag -}} |
| 47 | +{{- if (eq $safeVersion "shuri") -}} |
| 48 | + {{- $safeVersion = "v20.07.1" -}} |
| 49 | +{{- else if (regexMatch "^[^v].*" $safeVersion) -}} |
| 50 | + {{- $safeVersion = "v50.0.0" -}} |
| 51 | +{{- end -}} |
| 52 | +{{- printf "%s" $safeVersion -}} |
| 53 | +{{- end -}} |
| 54 | + |
| 55 | + |
| 56 | +{{/* |
| 57 | +Return the backups image name |
| 58 | +*/}} |
| 59 | +{{- define "dgraph.backups.image" -}} |
| 60 | +{{- $registryName := .Values.backups.image.registry -}} |
| 61 | +{{- $repositoryName := .Values.backups.image.repository -}} |
| 62 | +{{- $tag := .Values.backups.image.tag | toString -}} |
| 63 | +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} |
| 64 | +{{- end -}} |
| 65 | + |
| 66 | +{{/* |
| 67 | +Return the ratel image name |
| 68 | +*/}} |
| 69 | +{{- define "dgraph.ratel.image" -}} |
| 70 | +{{- $registryName := .Values.ratel.image.registry -}} |
| 71 | +{{- $repositoryName := .Values.ratel.image.repository -}} |
| 72 | +{{- $tag := .Values.ratel.image.tag | toString -}} |
| 73 | +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} |
| 74 | +{{- end -}} |
| 75 | + |
| 76 | + |
| 77 | +{{/* |
| 78 | +Return empty string if minio keys are not defined |
| 79 | +*/}} |
| 80 | +{{- define "dgraph.backups.keys.minio.enabled" -}} |
| 81 | +{{- $minioEnabled := "" -}} |
| 82 | +{{- $backupsEnabled := or .Values.backups.full.enabled .Values.backups.incremental.enabled }} |
| 83 | +{{- if $backupsEnabled -}} |
| 84 | + {{- if .Values.backups.keys -}} |
| 85 | + {{- if .Values.backups.keys.minio -}} |
| 86 | + {{- if and .Values.backups.keys.minio.access .Values.backups.keys.minio.secret -}} |
| 87 | + {{- $minioEnabled = true -}} |
| 88 | + {{- end -}} |
| 89 | + {{- end -}} |
| 90 | + {{- end -}} |
| 91 | +{{- end -}} |
| 92 | +{{- printf "%s" $minioEnabled -}} |
| 93 | +{{- end -}} |
| 94 | + |
| 95 | +{{/* |
| 96 | +Return empty string if s3 keys are not defined |
| 97 | +*/}} |
| 98 | +{{- define "dgraph.backups.keys.s3.enabled" -}} |
| 99 | +{{- $s3Enabled := "" -}} |
| 100 | +{{- $backupsEnabled := or .Values.backups.full.enabled .Values.backups.incremental.enabled }} |
| 101 | +{{- if $backupsEnabled -}} |
| 102 | + {{- if .Values.backups.keys -}} |
| 103 | + {{- if .Values.backups.keys.s3 -}} |
| 104 | + {{- if and .Values.backups.keys.s3.access .Values.backups.keys.s3.secret -}} |
| 105 | + {{- $s3Enabled = true -}} |
| 106 | + {{- end -}} |
| 107 | + {{- end -}} |
| 108 | + {{- end -}} |
| 109 | +{{- end -}} |
| 110 | +{{- printf "%s" $s3Enabled -}} |
| 111 | +{{- end -}} |
| 112 | + |
| 113 | +{{/* |
| 114 | +Return the initContainers image name |
| 115 | +*/}} |
| 116 | +{{- define "dgraph.initContainers.init.image" -}} |
| 117 | +{{- $registryName := .Values.alpha.initContainers.init.image.registry -}} |
| 118 | +{{- $repositoryName := .Values.alpha.initContainers.init.image.repository -}} |
| 119 | +{{- $tag := .Values.alpha.initContainers.init.image.tag | toString -}} |
| 120 | +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} |
| 121 | +{{- end -}} |
| 122 | + |
| 123 | +{{/* |
| 124 | +Return the proper image name (for the metrics image) |
| 125 | +*/}} |
| 126 | +{{- define "dgraph.image" -}} |
| 127 | +{{- $registryName := .Values.image.registry -}} |
| 128 | +{{- $repositoryName := .Values.image.repository -}} |
| 129 | +{{- $tag := .Values.image.tag | toString -}} |
| 130 | +{{/* |
| 131 | +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, |
| 132 | +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. |
| 133 | +Also, we can't use a single if because lazy evaluation is not an option |
| 134 | +*/}} |
| 135 | +{{- if .Values.global }} |
| 136 | + {{- if .Values.global.imageRegistry }} |
| 137 | + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} |
| 138 | + {{- else -}} |
| 139 | + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} |
| 140 | + {{- end -}} |
| 141 | +{{- else -}} |
| 142 | + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} |
| 143 | +{{- end -}} |
| 144 | +{{- end -}} |
| 145 | + |
| 146 | +{{/* |
| 147 | +Return the proper Docker Image Registry Secret Names |
| 148 | +*/}} |
| 149 | +{{- define "dgraph.imagePullSecrets" -}} |
| 150 | +{{/* |
| 151 | +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, |
| 152 | +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. |
| 153 | +Also, we can't use a single if because lazy evaluation is not an option |
| 154 | +*/}} |
| 155 | +{{- if .Values.global }} |
| 156 | +{{- if .Values.global.imagePullSecrets }} |
| 157 | +imagePullSecrets: |
| 158 | +{{- range .Values.global.imagePullSecrets }} |
| 159 | + - name: {{ . }} |
| 160 | +{{- end }} |
| 161 | +{{- else if .Values.image.pullSecrets }} |
| 162 | +imagePullSecrets: |
| 163 | +{{- range .Values.image.pullSecrets }} |
| 164 | + - name: {{ . }} |
| 165 | +{{- end }} |
| 166 | +{{- end -}} |
| 167 | +{{- else if .Values.image.pullSecrets }} |
| 168 | +imagePullSecrets: |
| 169 | +{{- range .Values.image.pullSecrets }} |
| 170 | + - name: {{ . }} |
| 171 | +{{- end }} |
| 172 | +{{- end -}} |
| 173 | +{{- end -}} |
| 174 | + |
| 175 | +{{/* |
| 176 | +Create a default fully qualified alpha name. |
| 177 | +*/}} |
| 178 | +{{- define "dgraph.alpha.fullname" -}} |
| 179 | +{{ template "dgraph.fullname" . }}-{{ .Values.alpha.name }} |
| 180 | +{{- end -}} |
| 181 | + |
| 182 | +{{/* |
| 183 | +Create the name of the service account to use |
| 184 | +*/}} |
| 185 | +{{- define "dgraph.serviceAccountName" -}} |
| 186 | +{{- if .Values.serviceAccount.create }} |
| 187 | +{{- default (include "dgraph.fullname" .) .Values.serviceAccount.name }} |
| 188 | +{{- else }} |
| 189 | +{{- default "default" .Values.serviceAccount.name }} |
| 190 | +{{- end }} |
| 191 | +{{- end }} |
| 192 | + |
| 193 | +{{/* |
| 194 | +Create a default fully qualified ratel name. |
| 195 | +*/}} |
| 196 | +{{- define "dgraph.ratel.fullname" -}} |
| 197 | +{{ template "dgraph.fullname" . }}-{{ .Values.ratel.name }} |
| 198 | +{{- end -}} |
| 199 | + |
| 200 | +{{/* |
| 201 | +Allow overriding namespace |
| 202 | +*/}} |
| 203 | +{{- define "dgraph.namespace" -}} |
| 204 | +{{- default .Release.Namespace .Values.namespaceOverride -}} |
| 205 | +{{- end -}} |
0 commit comments