3 SPDX-License-Identifier: APACHE-2.0
7 {{/* vim: set filetype=mustache: */}}
9 Validate Redis® required passwords are not empty.
12 {{ include "common.validations.values.redis.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
14 - secret - String - Required. Name of the secret where redis values are stored, e.g: "redis-passwords-secret"
15 - subchart - Boolean - Optional. Whether redis is used as subchart or not. Default: false
17 {{- define "common.validations.values.redis.passwords" -}}
18 {{- $enabled := include "common.redis.values.enabled" . -}}
19 {{- $valueKeyPrefix := include "common.redis.values.keys.prefix" . -}}
20 {{- $standarizedVersion := include "common.redis.values.standarized.version" . }}
22 {{- $existingSecret := ternary (printf "%s%s" $valueKeyPrefix "auth.existingSecret") (printf "%s%s" $valueKeyPrefix "existingSecret") (eq $standarizedVersion "true") }}
23 {{- $existingSecretValue := include "common.utils.getValueFromKey" (dict "key" $existingSecret "context" .context) }}
25 {{- $valueKeyRedisPassword := ternary (printf "%s%s" $valueKeyPrefix "auth.password") (printf "%s%s" $valueKeyPrefix "password") (eq $standarizedVersion "true") }}
26 {{- $valueKeyRedisUseAuth := ternary (printf "%s%s" $valueKeyPrefix "auth.enabled") (printf "%s%s" $valueKeyPrefix "usePassword") (eq $standarizedVersion "true") }}
28 {{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
29 {{- $requiredPasswords := list -}}
31 {{- $useAuth := include "common.utils.getValueFromKey" (dict "key" $valueKeyRedisUseAuth "context" .context) -}}
32 {{- if eq $useAuth "true" -}}
33 {{- $requiredRedisPassword := dict "valueKey" $valueKeyRedisPassword "secret" .secret "field" "redis-password" -}}
34 {{- $requiredPasswords = append $requiredPasswords $requiredRedisPassword -}}
37 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
42 Auxiliary function to get the right value for enabled redis.
45 {{ include "common.redis.values.enabled" (dict "context" $) }}
47 {{- define "common.redis.values.enabled" -}}
49 {{- printf "%v" .context.Values.redis.enabled -}}
51 {{- printf "%v" (not .context.Values.enabled) -}}
56 Auxiliary function to get the right prefix path for the values
59 {{ include "common.redis.values.key.prefix" (dict "subchart" "true" "context" $) }}
61 - subchart - Boolean - Optional. Whether redis is used as subchart or not. Default: false
63 {{- define "common.redis.values.keys.prefix" -}}
64 {{- if .subchart -}}redis.{{- else -}}{{- end -}}
68 Checks whether the redis chart's includes the standarizations (version >= 14)
71 {{ include "common.redis.values.standarized.version" (dict "context" $) }}
73 {{- define "common.redis.values.standarized.version" -}}
75 {{- $standarizedAuth := printf "%s%s" (include "common.redis.values.keys.prefix" .) "auth" -}}
76 {{- $standarizedAuthValues := include "common.utils.getValueFromKey" (dict "key" $standarizedAuth "context" .context) }}
78 {{- if $standarizedAuthValues -}}