From 293813726cf3f73f4c3f0f78036c50df76353d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mich=C3=A9e=20Lengronne?= Date: Thu, 6 Feb 2025 11:20:55 +0100 Subject: [PATCH] test validate values --- charts/trino/templates/NOTES.txt | 2 ++ charts/trino/templates/_helpers.tpl | 20 ++++++++++++++++++++ charts/trino/templates/ingress.yaml | 2 +- charts/trino/values.yaml | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/charts/trino/templates/NOTES.txt b/charts/trino/templates/NOTES.txt index 90930a1d..d211d7af 100644 --- a/charts/trino/templates/NOTES.txt +++ b/charts/trino/templates/NOTES.txt @@ -8,3 +8,5 @@ Get the application URL by running these commands: echo "Visit http://127.0.0.1:8080 to use your application" kubectl port-forward $POD_NAME 8080:8080 {{- end }} + +{{- include "trino.validateValues" . }} diff --git a/charts/trino/templates/_helpers.tpl b/charts/trino/templates/_helpers.tpl index e6023abd..840cf7f6 100644 --- a/charts/trino/templates/_helpers.tpl +++ b/charts/trino/templates/_helpers.tpl @@ -155,3 +155,23 @@ Create the secret name for the group-provider file {{- end }} {{- end }} {{- end }} + +{{/* Compile all validation warnings into a single message and call fail. */}} +{{- define "trino.validateValues" -}} +{{- $messages := list -}} +{{- $messages = append $messages (include "mychart.validateValues.httpsonly.enabled" .) -}} +{{- $messages = without $messages "" -}} +{{- $message := join "\n" $messages -}} + +{{- if $message -}} +{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}} +{{- end -}} +{{- end -}} + +{{/* Validate value of https.only */}} +{{- define "mychart.validateValues.httpsonly" -}} +{{- if and .Values.server.config.https.only (not .Values.server.config.https.enabled) -}} +trino: .Values.server.config.https.only + `.Values.server.config.https.only` requires .Values.server.config.https.enabled +{{- end -}} +{{- end -}} diff --git a/charts/trino/templates/ingress.yaml b/charts/trino/templates/ingress.yaml index b41dd8c1..934e07d1 100644 --- a/charts/trino/templates/ingress.yaml +++ b/charts/trino/templates/ingress.yaml @@ -32,7 +32,7 @@ spec: service: name: {{ include "trino.fullname" $ }} port: - {{- if $.Values.ingress.tlsService }} + {{- if and $.Values.server.config.https.enabled $.Values.ingress.tlsService }} number: {{ $.Values.service.tlsPort }} {{- else }} number: {{ $.Values.service.port }} diff --git a/charts/trino/values.yaml b/charts/trino/values.yaml index 404bdab2..a11d8b31 100644 --- a/charts/trino/values.yaml +++ b/charts/trino/values.yaml @@ -53,6 +53,8 @@ server: enabled: false # -- Enable communications between coordinator and workers through https. It depends on https being enabled internal: false + # -- Disable http server completely. It requires https.internal and ingress.tlsService (if Ingress is configured) + only: false keystore: path: "" key: ""