docs and validation

This commit is contained in:
David J. M. Karlsen
2019-12-10 14:01:56 +01:00
parent 1b4391e2c2
commit e5bee1a40b
2 changed files with 38 additions and 0 deletions

View File

@@ -17,3 +17,5 @@ To access the Memcached Prometheus metrics from outside the cluster execute the
curl http://127.0.0.1:{{ .Values.metrics.service.port }}/metrics
{{- end }}
{{- include "memcached.validateValues" . }}

View File

@@ -165,6 +165,42 @@ but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else
{{- end -}}
{{- end -}}
{{/*
Compile all warnings into a single message, and call fail.
*/}}
{{- define "memcached.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "memcached.validateValues.architecture" .) -}}
{{- $messages := append $messages (include "memcached.validateValues.replicaCount" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}
{{/* Validate values of Memcached - must provide a valid architecture */}}
{{- define "memcached.validateValues.architecture" -}}
{{- if and (ne .Values.architecture "standalone") (ne .Values.architecture "high-availability") -}}
memcached: architecture
Invalid architecture selected. Valid values are "standalone" and
"high-availability". Please set a valid architecture (--set architecture="xxxx")
{{- end -}}
{{- end -}}
{{/* Validate values of InfluxDB - number of replicas */}}
{{- define "memcached.validateValues.replicaCount" -}}
{{- $replicaCount := int .Values.replicaCount }}
{{- if and (eq .Values.architecture "standalone") (gt $replicaCount 1) -}}
memcached: replicaCount
The standalone architecture doesn't allow to run more than 1 replica.
Please set a valid number of replicas (--set memcached.replicaCount=1) or
use the "high-availability" architecture (--set architecture="high-availability")
{{- end -}}
{{- end -}}
{{/*
Renders a value that contains template.
Usage: