[bitnami/common] add psql and mysql required password validations (#3374)

* feat(common): add psql and mysql required password validations
This commit is contained in:
Daniel Arteaga
2020-08-10 12:16:53 +02:00
committed by GitHub
parent 28dfe8395c
commit 1a4419e15d
4 changed files with 133 additions and 56 deletions

View File

@@ -3,23 +3,18 @@
Through error when upgrading using empty passwords values that must not be empty.
Usage:
{{- $requiredPasswordConf00 := (dict "valueKey" "path.to.password00" "secret" "secretName" "field" "password-00") -}}
{{- $requiredPasswordConf01 := (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}}
{{ include "common.errors.upgrade.passwords.empty" (dict "required" (list $requiredPasswordConf00 $requiredPasswordConf01) "context" $) }}
{{- $validationError00 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password00" "secret" "secretName" "field" "password-00") -}}
{{- $validationError01 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}}
{{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }}
Required password params:
- valueKey - String - Required. The path to the required password in the values.yaml, e.g: "mysql.password"
- secret - String - Required. Name of the secret where the password is generated/stored, e.g: "mysql-passwords-secret"
- field - String - Required. Name of the field in the secret data, e.g: "mysql-password"
- validationErrors - String - Required. List of validation strings to be return, if it is empty it won't throw error.
- context - Context - Required. Parent context.
*/}}
{{- define "common.errors.upgrade.passwords.empty" -}}
{{- if .context.Release.IsUpgrade -}}
{{- $validationErrors := include "common.validations.values.multiple.empty" . -}}
{{- if $validationErrors -}}
{{- $validationErrors := join "" .validationErrors -}}
{{- if and $validationErrors .context.Release.IsUpgrade -}}
{{- $errorString := "\nPASSWORDS ERROR: you must provide your current passwords when upgrade the release%s" -}}
{{- printf $errorString $validationErrors | fail -}}
{{- end -}}
{{- end -}}
{{- end -}}