1 {{/* vim: set filetype=mustache: */}}
3 Validate values must not be empty.
6 {{- $validateValueConf00 := (dict "valueKey" "path.to.value" "secret" "secretName" "field" "password-00") -}}
7 {{- $validateValueConf01 := (dict "valueKey" "path.to.value" "secret" "secretName" "field" "password-01") -}}
8 {{ include "common.validations.values.empty" (dict "required" (list $validateValueConf00 $validateValueConf01) "context" $) }}
10 Validate value params:
11 - valueKey - String - Required. The path to the validating value in the values.yaml, e.g: "mysql.password"
12 - secret - String - Optional. Name of the secret where the validating value is generated/stored, e.g: "mysql-passwords-secret"
13 - field - String - Optional. Name of the field in the secret data, e.g: "mysql-password"
15 {{- define "common.validations.values.multiple.empty" -}}
16 {{- range .required -}}
17 {{- include "common.validations.values.single.empty" (dict "valueKey" .valueKey "secret" .secret "field" .field "context" $.context) -}}
22 Validate a value must not be empty.
25 {{ include "common.validations.value.empty" (dict "valueKey" "mariadb.password" "secret" "secretName" "field" "my-password" "context" $) }}
27 Validate value params:
28 - valueKey - String - Required. The path to the validating value in the values.yaml, e.g: "mysql.password"
29 - secret - String - Optional. Name of the secret where the validating value is generated/stored, e.g: "mysql-passwords-secret"
30 - field - String - Optional. Name of the field in the secret data, e.g: "mysql-password"
32 {{- define "common.validations.values.single.empty" -}}
33 {{- $value := include "common.utils.getValueFromKey" (dict "key" .valueKey "context" .context) }}
36 {{- $varname := "my-value" -}}
37 {{- $getCurrentValue := "" -}}
38 {{- if and .secret .field -}}
39 {{- $varname = include "common.utils.fieldToEnvVar" . -}}
40 {{- $getCurrentValue = printf " To get the current value:\n\n %s\n" (include "common.utils.secret.getvalue" .) -}}
42 {{- printf "\n '%s' must not be empty, please add '--set %s=$%s' to the command.%s" .valueKey .valueKey $varname $getCurrentValue -}}
47 Validate MariaDB required passwords are not empty.
50 {{ include "common.validations.values.mariadb.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
52 - secret - String - Required. Name of the secret where MariaDB values are stored, e.g: "mysql-passwords-secret"
53 - subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
55 {{- define "common.validations.values.mariadb.passwords" -}}
56 {{- $existingSecret := include "common.mariadb.values.existingSecret" . -}}
57 {{- $enabled := include "common.mariadb.values.enabled" . -}}
58 {{- $architecture := include "common.mariadb.values.architecture" . -}}
59 {{- $authPrefix := include "common.mariadb.values.key.auth" . -}}
60 {{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
61 {{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
62 {{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
63 {{- $valueKeyReplicationPassword := printf "%s.replicationPassword" $authPrefix -}}
65 {{- if and (not $existingSecret) (eq $enabled "true") -}}
66 {{- $requiredPasswords := list -}}
68 {{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mariadb-root-password" -}}
69 {{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
71 {{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
72 {{- if not (empty $valueUsername) -}}
73 {{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mariadb-password" -}}
74 {{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
77 {{- if (eq $architecture "replication") -}}
78 {{- $requiredReplicationPassword := dict "valueKey" $valueKeyReplicationPassword "secret" .secret "field" "mariadb-replication-password" -}}
79 {{- $requiredPasswords = append $requiredPasswords $requiredReplicationPassword -}}
82 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
88 Auxiliar function to get the right value for existingSecret.
91 {{ include "common.mariadb.values.existingSecret" (dict "context" $) }}
93 - subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
95 {{- define "common.mariadb.values.existingSecret" -}}
97 {{- .context.Values.mariadb.existingSecret | quote -}}
99 {{- .context.Values.existingSecret | quote -}}
104 Auxiliar function to get the right value for enabled mariadb.
107 {{ include "common.mariadb.values.enabled" (dict "context" $) }}
109 {{- define "common.mariadb.values.enabled" -}}
111 {{- printf "%v" .context.Values.mariadb.enabled -}}
113 {{- printf "%v" (not .context.Values.enabled) -}}
118 Auxiliar function to get the right value for architecture
121 {{ include "common.mariadb.values.architecture" (dict "subchart" "true" "context" $) }}
123 - subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
125 {{- define "common.mariadb.values.architecture" -}}
127 {{- .context.Values.mariadb.architecture -}}
129 {{- .context.Values.architecture -}}
134 Auxiliar function to get the right value for the key auth
137 {{ include "common.mariadb.values.key.auth" (dict "subchart" "true" "context" $) }}
139 - subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
141 {{- define "common.mariadb.values.key.auth" -}}
150 Validate PostgreSQL required passwords are not empty.
153 {{ include "common.validations.values.postgresql.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
155 - secret - String - Required. Name of the secret where postgresql values are stored, e.g: "mysql-passwords-secret"
156 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
158 {{- define "common.validations.values.postgresql.passwords" -}}
159 {{- $existingSecret := include "common.postgresql.values.existingSecret" . -}}
160 {{- $enabled := include "common.postgresql.values.enabled" . -}}
161 {{- $valueKeyPostgresqlPassword := include "common.postgresql.values.key.postgressPassword" . -}}
162 {{- $enabledReplication := include "common.postgresql.values.enabled.replication" . -}}
163 {{- $valueKeyPostgresqlReplicationEnabled := include "common.postgresql.values.key.replicationPassword" . -}}
165 {{- if and (not $existingSecret) (eq $enabled "true") -}}
166 {{- $requiredPasswords := list -}}
168 {{- $requiredPostgresqlPassword := dict "valueKey" $valueKeyPostgresqlPassword "secret" .secret "field" "postgresql-password" -}}
169 {{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlPassword -}}
171 {{- if (eq $enabledReplication "true") -}}
172 {{- $requiredPostgresqlReplicationPassword := dict "valueKey" $valueKeyPostgresqlReplicationEnabled "secret" .secret "field" "postgresql-replication-password" -}}
173 {{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlReplicationPassword -}}
176 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
181 Auxiliar function to decide whether evaluate global values.
184 {{ include "common.postgresql.values.use.global" (dict "key" "key-of-global" "context" $) }}
186 - key - String - Required. Field to be evaluated within global, e.g: "existingSecret"
188 {{- define "common.postgresql.values.use.global" -}}
189 {{- if .context.Values.global -}}
190 {{- if .context.Values.global.postgresql -}}
191 {{- index .context.Values.global.postgresql .key | quote -}}
197 Auxiliar function to get the right value for existingSecret.
200 {{ include "common.postgresql.values.existingSecret" (dict "context" $) }}
202 {{- define "common.postgresql.values.existingSecret" -}}
203 {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "existingSecret" "context" .context) -}}
206 {{- default (.context.Values.postgresql.existingSecret | quote) $globalValue -}}
208 {{- default (.context.Values.existingSecret | quote) $globalValue -}}
213 Auxiliar function to get the right value for enabled postgresql.
216 {{ include "common.postgresql.values.enabled" (dict "context" $) }}
218 {{- define "common.postgresql.values.enabled" -}}
220 {{- printf "%v" .context.Values.postgresql.enabled -}}
222 {{- printf "%v" (not .context.Values.enabled) -}}
227 Auxiliar function to get the right value for the key postgressPassword.
230 {{ include "common.postgresql.values.key.postgressPassword" (dict "subchart" "true" "context" $) }}
232 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
234 {{- define "common.postgresql.values.key.postgressPassword" -}}
235 {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "postgresqlUsername" "context" .context) -}}
237 {{- if not $globalValue -}}
239 postgresql.postgresqlPassword
244 global.postgresql.postgresqlPassword
249 Auxiliar function to get the right value for enabled.replication.
252 {{ include "common.postgresql.values.enabled.replication" (dict "subchart" "true" "context" $) }}
254 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
256 {{- define "common.postgresql.values.enabled.replication" -}}
258 {{- printf "%v" .context.Values.postgresql.replication.enabled -}}
260 {{- printf "%v" .context.Values.replication.enabled -}}
265 Auxiliar function to get the right value for the key replication.password.
268 {{ include "common.postgresql.values.key.replicationPassword" (dict "subchart" "true" "context" $) }}
270 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
272 {{- define "common.postgresql.values.key.replicationPassword" -}}
274 postgresql.replication.password