1 {{/* vim: set filetype=mustache: */}}
3 Validate MongoDB® required passwords are not empty.
6 {{ include "common.validations.values.mongodb.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
8 - secret - String - Required. Name of the secret where MongoDB® values are stored, e.g: "mongodb-passwords-secret"
9 - subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
11 {{- define "common.validations.values.mongodb.passwords" -}}
12 {{- $existingSecret := include "common.mongodb.values.auth.existingSecret" . -}}
13 {{- $enabled := include "common.mongodb.values.enabled" . -}}
14 {{- $authPrefix := include "common.mongodb.values.key.auth" . -}}
15 {{- $architecture := include "common.mongodb.values.architecture" . -}}
16 {{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
17 {{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
18 {{- $valueKeyDatabase := printf "%s.database" $authPrefix -}}
19 {{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
20 {{- $valueKeyReplicaSetKey := printf "%s.replicaSetKey" $authPrefix -}}
21 {{- $valueKeyAuthEnabled := printf "%s.enabled" $authPrefix -}}
23 {{- $authEnabled := include "common.utils.getValueFromKey" (dict "key" $valueKeyAuthEnabled "context" .context) -}}
25 {{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") (eq $authEnabled "true") -}}
26 {{- $requiredPasswords := list -}}
28 {{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mongodb-root-password" -}}
29 {{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
31 {{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
32 {{- $valueDatabase := include "common.utils.getValueFromKey" (dict "key" $valueKeyDatabase "context" .context) }}
33 {{- if and $valueUsername $valueDatabase -}}
34 {{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mongodb-password" -}}
35 {{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
38 {{- if (eq $architecture "replicaset") -}}
39 {{- $requiredReplicaSetKey := dict "valueKey" $valueKeyReplicaSetKey "secret" .secret "field" "mongodb-replica-set-key" -}}
40 {{- $requiredPasswords = append $requiredPasswords $requiredReplicaSetKey -}}
43 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
49 Auxiliary function to get the right value for existingSecret.
52 {{ include "common.mongodb.values.auth.existingSecret" (dict "context" $) }}
54 - subchart - Boolean - Optional. Whether MongoDb is used as subchart or not. Default: false
56 {{- define "common.mongodb.values.auth.existingSecret" -}}
58 {{- .context.Values.mongodb.auth.existingSecret | quote -}}
60 {{- .context.Values.auth.existingSecret | quote -}}
65 Auxiliary function to get the right value for enabled mongodb.
68 {{ include "common.mongodb.values.enabled" (dict "context" $) }}
70 {{- define "common.mongodb.values.enabled" -}}
72 {{- printf "%v" .context.Values.mongodb.enabled -}}
74 {{- printf "%v" (not .context.Values.enabled) -}}
79 Auxiliary function to get the right value for the key auth
82 {{ include "common.mongodb.values.key.auth" (dict "subchart" "true" "context" $) }}
84 - subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
86 {{- define "common.mongodb.values.key.auth" -}}
95 Auxiliary function to get the right value for architecture
98 {{ include "common.mongodb.values.architecture" (dict "subchart" "true" "context" $) }}
100 - subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
102 {{- define "common.mongodb.values.architecture" -}}
104 {{- .context.Values.mongodb.architecture -}}
106 {{- .context.Values.architecture -}}