[APACHE] Add Apache CNF use case files
[demo.git] / tutorials / ApacheCNF / templates / cba / Templates / k8s-configs / deployment-config / charts / common / templates / _errors.tpl
diff --git a/tutorials/ApacheCNF/templates/cba/Templates/k8s-configs/deployment-config/charts/common/templates/_errors.tpl b/tutorials/ApacheCNF/templates/cba/Templates/k8s-configs/deployment-config/charts/common/templates/_errors.tpl
new file mode 100644 (file)
index 0000000..d6d3ec6
--- /dev/null
@@ -0,0 +1,20 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Through error when upgrading using empty passwords values that must not be empty.
+
+Usage:
+{{- $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:
+  - 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" -}}
+  {{- $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 -}}