Skip to content

Instantly share code, notes, and snippets.

@etrikp
Created September 11, 2023 20:23
Show Gist options
  • Save etrikp/908ccb63383bba50404f856af4cd8eae to your computer and use it in GitHub Desktop.
Save etrikp/908ccb63383bba50404f856af4cd8eae to your computer and use it in GitHub Desktop.
haproxy-nginx
{{/*
Validate that only one of haproxy_gateway.enabled or nginx_gateway.enabled is set to true.
*/}}
{{- define "gateway.validate" -}}
{{- $haproxyEnabled := .Values.haproxy_gateway.enabled -}}
{{- $nginxEnabled := .Values.nginx_gateway.enabled -}}
{{- if and $haproxyEnabled $nginxEnabled -}}
{{- printf "Error: Both haproxy_gateway.enabled and nginx_gateway.enabled cannot be set to true simultaneously." -}}
{{- else if and (not $haproxyEnabled) (not $nginxEnabled) -}}
{{- printf "Error: Either haproxy_gateway.enabled or nginx_gateway.enabled must be set to true." -}}
{{- end -}}
{{- end -}}
{{- $gatewayError := include "gateway.validate" . }}
{{- if $gatewayError }}
apiVersion: v1
kind: ConfigMap
metadata:
name: error
data:
message: {{ $gatewayError | quote }}
{{- fail $gatewayError }}
{{- end }}
# The rest of your Helm templates here...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment