1 {{/* vim: set filetype=mustache: */}}
3 Validate MySQL required passwords are not empty.
6 {{ include "common.validations.values.mysql.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
8 - secret - String - Required. Name of the secret where MySQL values are stored, e.g: "mysql-passwords-secret"
9 - subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
11 {{- define "common.validations.values.mysql.passwords" -}}
12 {{- $existingSecret := include "common.mysql.values.auth.existingSecret" . -}}
13 {{- $enabled := include "common.mysql.values.enabled" . -}}
14 {{- $architecture := include "common.mysql.values.architecture" . -}}
15 {{- $authPrefix := include "common.mysql.values.key.auth" . -}}
16 {{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
17 {{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
18 {{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
19 {{- $valueKeyReplicationPassword := printf "%s.replicationPassword" $authPrefix -}}
21 {{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
22 {{- $requiredPasswords := list -}}
24 {{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mysql-root-password" -}}
25 {{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
27 {{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
28 {{- if not (empty $valueUsername) -}}
29 {{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mysql-password" -}}
30 {{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
33 {{- if (eq $architecture "replication") -}}
34 {{- $requiredReplicationPassword := dict "valueKey" $valueKeyReplicationPassword "secret" .secret "field" "mysql-replication-password" -}}
35 {{- $requiredPasswords = append $requiredPasswords $requiredReplicationPassword -}}
38 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
44 Auxiliary function to get the right value for existingSecret.
47 {{ include "common.mysql.values.auth.existingSecret" (dict "context" $) }}
49 - subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
51 {{- define "common.mysql.values.auth.existingSecret" -}}
53 {{- .context.Values.mysql.auth.existingSecret | quote -}}
55 {{- .context.Values.auth.existingSecret | quote -}}
60 Auxiliary function to get the right value for enabled mysql.
63 {{ include "common.mysql.values.enabled" (dict "context" $) }}
65 {{- define "common.mysql.values.enabled" -}}
67 {{- printf "%v" .context.Values.mysql.enabled -}}
69 {{- printf "%v" (not .context.Values.enabled) -}}
74 Auxiliary function to get the right value for architecture
77 {{ include "common.mysql.values.architecture" (dict "subchart" "true" "context" $) }}
79 - subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
81 {{- define "common.mysql.values.architecture" -}}
83 {{- .context.Values.mysql.architecture -}}
85 {{- .context.Values.architecture -}}
90 Auxiliary function to get the right value for the key auth
93 {{ include "common.mysql.values.key.auth" (dict "subchart" "true" "context" $) }}
95 - subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
97 {{- define "common.mysql.values.key.auth" -}}