3 SPDX-License-Identifier: APACHE-2.0
6 {{/* vim: set filetype=mustache: */}}
8 Validate MongoDB® required passwords are not empty.
11 {{ include "common.validations.values.mongodb.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
13 - secret - String - Required. Name of the secret where MongoDB® values are stored, e.g: "mongodb-passwords-secret"
14 - subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
16 {{- define "common.validations.values.mongodb.passwords" -}}
17 {{- $existingSecret := include "common.mongodb.values.auth.existingSecret" . -}}
18 {{- $enabled := include "common.mongodb.values.enabled" . -}}
19 {{- $authPrefix := include "common.mongodb.values.key.auth" . -}}
20 {{- $architecture := include "common.mongodb.values.architecture" . -}}
21 {{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
22 {{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
23 {{- $valueKeyDatabase := printf "%s.database" $authPrefix -}}
24 {{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
25 {{- $valueKeyReplicaSetKey := printf "%s.replicaSetKey" $authPrefix -}}
26 {{- $valueKeyAuthEnabled := printf "%s.enabled" $authPrefix -}}
28 {{- $authEnabled := include "common.utils.getValueFromKey" (dict "key" $valueKeyAuthEnabled "context" .context) -}}
30 {{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") (eq $authEnabled "true") -}}
31 {{- $requiredPasswords := list -}}
33 {{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mongodb-root-password" -}}
34 {{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
36 {{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
37 {{- $valueDatabase := include "common.utils.getValueFromKey" (dict "key" $valueKeyDatabase "context" .context) }}
38 {{- if and $valueUsername $valueDatabase -}}
39 {{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mongodb-password" -}}
40 {{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
43 {{- if (eq $architecture "replicaset") -}}
44 {{- $requiredReplicaSetKey := dict "valueKey" $valueKeyReplicaSetKey "secret" .secret "field" "mongodb-replica-set-key" -}}
45 {{- $requiredPasswords = append $requiredPasswords $requiredReplicaSetKey -}}
48 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
54 Auxiliary function to get the right value for existingSecret.
57 {{ include "common.mongodb.values.auth.existingSecret" (dict "context" $) }}
59 - subchart - Boolean - Optional. Whether MongoDb is used as subchart or not. Default: false
61 {{- define "common.mongodb.values.auth.existingSecret" -}}
63 {{- .context.Values.mongodb.auth.existingSecret | quote -}}
65 {{- .context.Values.auth.existingSecret | quote -}}
70 Auxiliary function to get the right value for enabled mongodb.
73 {{ include "common.mongodb.values.enabled" (dict "context" $) }}
75 {{- define "common.mongodb.values.enabled" -}}
77 {{- printf "%v" .context.Values.mongodb.enabled -}}
79 {{- printf "%v" (not .context.Values.enabled) -}}
84 Auxiliary function to get the right value for the key auth
87 {{ include "common.mongodb.values.key.auth" (dict "subchart" "true" "context" $) }}
89 - subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
91 {{- define "common.mongodb.values.key.auth" -}}
100 Auxiliary function to get the right value for architecture
103 {{ include "common.mongodb.values.architecture" (dict "subchart" "true" "context" $) }}
105 - subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
107 {{- define "common.mongodb.values.architecture" -}}
109 {{- .context.Values.mongodb.architecture -}}
111 {{- .context.Values.architecture -}}