From 205e4ca335af3bb01d47c2e12b5086ac64a06f1d Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Fri, 8 Dec 2023 02:28:09 +0200 Subject: [PATCH] more ingress validation --- library/common-test/tests/ingress/validation_test.yaml | 6 +++--- library/common/templates/lib/ingress/_validation.tpl | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/library/common-test/tests/ingress/validation_test.yaml b/library/common-test/tests/ingress/validation_test.yaml index bd7dd62c..23d7e3bb 100644 --- a/library/common-test/tests/ingress/validation_test.yaml +++ b/library/common-test/tests/ingress/validation_test.yaml @@ -584,10 +584,10 @@ tests: - hosts: - test-host secretName: test-secret - scaleCert: "1" + clusterCertificate: some-cert asserts: - failedTemplate: - errorMessage: Ingress - Expected only one of [scaleCert, secretName] to be set, but got [scaleCert, secretName] + errorMessage: Ingress - Expected only one of [scaleCert, secretName, certificateIssuer, clusterCertificate] to be set, but got [secretName, clusterCertificate] - it: should fail with scaleCert outside of SCALE set: @@ -604,4 +604,4 @@ tests: scaleCert: "1" asserts: - failedTemplate: - errorMessage: Ingress - [tls.scalecert] can only be used in TrueNAS SCALE + errorMessage: Ingress - [tls.scaleCert] can only be used in TrueNAS SCALE diff --git a/library/common/templates/lib/ingress/_validation.tpl b/library/common/templates/lib/ingress/_validation.tpl index 216ef5e9..cee39de0 100644 --- a/library/common/templates/lib/ingress/_validation.tpl +++ b/library/common/templates/lib/ingress/_validation.tpl @@ -96,6 +96,12 @@ objectData: {{- end -}} {{- range $t := $objectData.tls -}} + {{- if $t.scaleCert -}} + {{- if not $rootCtx.Values.global.ixChartContext -}} + {{- fail "Ingress - [tls.scaleCert] can only be used in TrueNAS SCALE" -}} + {{- end -}} + {{- end -}} + {{- if not $t.hosts -}} {{- fail "Ingress - Expected non-empty [tls.hosts]" -}} {{- end -}} @@ -121,8 +127,7 @@ objectData: {{- end -}} {{- end -}} - {{/* TODO: Add the rest of the options?! */}} - {{- $certOptions := (list "scaleCert" "secretName") -}} + {{- $certOptions := (list "scaleCert" "secretName" "certificateIssuer" "clusterCertificate") -}} {{- $optsSet := list -}} {{- range $opt := $certOptions -}} {{- if (get $t $opt) -}}