3 SPDX-License-Identifier: APACHE-2.0
6 {{/* vim: set filetype=mustache: */}}
8 Validate values must not be empty.
11 {{- $validateValueConf00 := (dict "valueKey" "path.to.value" "secret" "secretName" "field" "password-00") -}}
12 {{- $validateValueConf01 := (dict "valueKey" "path.to.value" "secret" "secretName" "field" "password-01") -}}
13 {{ include "common.validations.values.empty" (dict "required" (list $validateValueConf00 $validateValueConf01) "context" $) }}
15 Validate value params:
16 - valueKey - String - Required. The path to the validating value in the values.yaml, e.g: "mysql.password"
17 - secret - String - Optional. Name of the secret where the validating value is generated/stored, e.g: "mysql-passwords-secret"
18 - field - String - Optional. Name of the field in the secret data, e.g: "mysql-password"
20 {{- define "common.validations.values.multiple.empty" -}}
21 {{- range .required -}}
22 {{- include "common.validations.values.single.empty" (dict "valueKey" .valueKey "secret" .secret "field" .field "context" $.context) -}}
27 Validate a value must not be empty.
30 {{ include "common.validations.value.empty" (dict "valueKey" "mariadb.password" "secret" "secretName" "field" "my-password" "subchart" "subchart" "context" $) }}
32 Validate value params:
33 - valueKey - String - Required. The path to the validating value in the values.yaml, e.g: "mysql.password"
34 - secret - String - Optional. Name of the secret where the validating value is generated/stored, e.g: "mysql-passwords-secret"
35 - field - String - Optional. Name of the field in the secret data, e.g: "mysql-password"
36 - subchart - String - Optional - Name of the subchart that the validated password is part of.
38 {{- define "common.validations.values.single.empty" -}}
39 {{- $value := include "common.utils.getValueFromKey" (dict "key" .valueKey "context" .context) }}
40 {{- $subchart := ternary "" (printf "%s." .subchart) (empty .subchart) }}
43 {{- $varname := "my-value" -}}
44 {{- $getCurrentValue := "" -}}
45 {{- if and .secret .field -}}
46 {{- $varname = include "common.utils.fieldToEnvVar" . -}}
47 {{- $getCurrentValue = printf " To get the current value:\n\n %s\n" (include "common.utils.secret.getvalue" .) -}}
49 {{- printf "\n '%s' must not be empty, please add '--set %s%s=$%s' to the command.%s" .valueKey $subchart .valueKey $varname $getCurrentValue -}}