From 6f7c94fbb471d0c55a988f56c4e2d0ecb82f7c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Audun-Marius=20Gangst=C3=B8?= Date: Fri, 12 Dec 2025 15:40:22 +0900 Subject: [PATCH 1/3] add helm_template_compare helper for tests --- varnish-enterprise/test/unit/_helpers.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/varnish-enterprise/test/unit/_helpers.bash b/varnish-enterprise/test/unit/_helpers.bash index 12771fa..43e4aca 100644 --- a/varnish-enterprise/test/unit/_helpers.bash +++ b/varnish-enterprise/test/unit/_helpers.bash @@ -2,6 +2,20 @@ chart_dir() { echo "${BATS_TEST_DIRNAME}"/../.. } +helm_template_compare { + local valuefile="${BATS_TMPDIR}/values-${BATS_TEST_NUMBER}" + echo "$1" > "$valuefile" + local templatefile="$2" + local jqpattern="$3" + local expected_result="$4" + local result=$(helm template --namespace default\ + --values "$valuefile" \ + --show-only "$templatefile" | + yq -c "$jqpattern" + )" + [ "$result" == "$expected_result ] +} + app_version() { yq -r '.appVersion' < "${BATS_TEST_DIRNAME}"/../../Chart.yaml } From 91ab9de2f0bdea28a8ab0fcb53439cab80883543 Mon Sep 17 00:00:00 2001 From: Brian Stewart Date: Tue, 9 Dec 2025 14:32:01 -0800 Subject: [PATCH 2/3] add repoType option --- varnish-cache/test/unit/deployment.bats | 2 +- varnish-enterprise/templates/_helpers.tpl | 29 ++++++++++++++++---- varnish-enterprise/test/unit/_helpers.bash | 10 ++++--- varnish-enterprise/test/unit/deployment.bats | 2 +- varnish-enterprise/test/unit/repotype.bats | 27 ++++++++++++++++++ varnish-enterprise/values.yaml | 10 ++++++- 6 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 varnish-enterprise/test/unit/repotype.bats diff --git a/varnish-cache/test/unit/deployment.bats b/varnish-cache/test/unit/deployment.bats index 2c1725b..852783f 100644 --- a/varnish-cache/test/unit/deployment.bats +++ b/varnish-cache/test/unit/deployment.bats @@ -101,4 +101,4 @@ rollingUpdate: tee -a /dev/stderr) [[ "${actual}" == *"'server.extraVolumeClaimTemplates' cannot be enabled"* ]] -} +} \ No newline at end of file diff --git a/varnish-enterprise/templates/_helpers.tpl b/varnish-enterprise/templates/_helpers.tpl index 0d17045..532761d 100644 --- a/varnish-enterprise/templates/_helpers.tpl +++ b/varnish-enterprise/templates/_helpers.tpl @@ -35,12 +35,31 @@ Create chart name and version as used by the chart label. {{/* Sets up the Varnish Enterprise image and its overrides (if any) */}} -{{- define "varnish-enterprise.image" }} -{{- $base := .base | default dict }} -{{- $image := .image | default dict }} -image: "{{- if eq $image.repository "-" -}}{{ $base.repository }}{{ else }}{{ $image.repository }}{{ end }}:{{- if eq $image.tag "-" }}{{ default .Chart.AppVersion $base.tag }}{{ else }}{{ default $.Chart.AppVersion $image.tag }}{{ end }}" +{{- define "varnish-enterprise.image" -}} +{{- $base := .base | default dict -}} +{{- $image := .image | default dict -}} + +{{- $repoType := .Values.global.repoType | default "" -}} +{{- $calculatedRepo := $base.repository -}} + +{{- if eq $repoType "public-enterprise" }} + {{- $calculatedRepo = "varnish/varnish-enterprise" }} +{{- else if eq $repoType "private-enterprise" }} + {{- $calculatedRepo = "quay.io/varnish-software/varnish-plus" }} +{{ end }} +image: "{{- if eq $image.repository "-" -}} + {{ $calculatedRepo }} + {{- else -}} + {{ $image.repository }} y + {{- end -}} + : + {{- if eq $image.tag "-" }} + {{ default .Chart.AppVersion $base.tag }} + {{- else -}} + {{ default $.Chart.AppVersion $image.tag }} + {{- end -}}" imagePullPolicy: {{ if eq $image.pullPolicy "-" }}{{ $base.pullPolicy }}{{ else }}{{ $image.pullPolicy }}{{ end }} -{{- end }} +{{- end -}} {{/* Converts size string (e.g. 10Mi or 10M) to a number diff --git a/varnish-enterprise/test/unit/_helpers.bash b/varnish-enterprise/test/unit/_helpers.bash index 43e4aca..7517dff 100644 --- a/varnish-enterprise/test/unit/_helpers.bash +++ b/varnish-enterprise/test/unit/_helpers.bash @@ -2,18 +2,20 @@ chart_dir() { echo "${BATS_TEST_DIRNAME}"/../.. } -helm_template_compare { +helm_template_compare() { local valuefile="${BATS_TMPDIR}/values-${BATS_TEST_NUMBER}" echo "$1" > "$valuefile" local templatefile="$2" local jqpattern="$3" local expected_result="$4" + local result=$(helm template --namespace default\ --values "$valuefile" \ - --show-only "$templatefile" | + --show-only "$templatefile" "$(chart_dir)" | yq -c "$jqpattern" - )" - [ "$result" == "$expected_result ] + ) + + [ "$result" == "$expected_result" ] } app_version() { diff --git a/varnish-enterprise/test/unit/deployment.bats b/varnish-enterprise/test/unit/deployment.bats index 524ef64..fba03f6 100644 --- a/varnish-enterprise/test/unit/deployment.bats +++ b/varnish-enterprise/test/unit/deployment.bats @@ -151,4 +151,4 @@ rollingUpdate: tee -a /dev/stderr) [[ "${actual}" == *"'server.extraVolumeClaimTemplates' cannot be enabled"* ]] -} +} \ No newline at end of file diff --git a/varnish-enterprise/test/unit/repotype.bats b/varnish-enterprise/test/unit/repotype.bats new file mode 100644 index 0000000..41ac59d --- /dev/null +++ b/varnish-enterprise/test/unit/repotype.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +load _helpers + +@test "repoType: default (no global.repoType set)" { + helm_template_compare \ + "global: {}" \ + "templates/deployment.yaml" \ + '.spec.template.spec.containers[0].image' \ + "\"quay.io/varnish-software/varnish-plus:$(app_version)\"" +} + +@test "repoType: public-enterprise" { + helm_template_compare \ + "global: {repoType: public-enterprise}" \ + "templates/deployment.yaml" \ + '.spec.template.spec.containers[0].image' \ + "\"varnish/varnish-enterprise:$(app_version)\"" +} + +@test "repoType: private-enterprise" { + helm_template_compare \ + "global: {repoType: private-enterprise}" \ + "templates/deployment.yaml" \ + '.spec.template.spec.containers[0].image' \ + "\"quay.io/varnish-software/varnish-plus:$(app_version)\"" +} \ No newline at end of file diff --git a/varnish-enterprise/values.yaml b/varnish-enterprise/values.yaml index 23223f5..224f126 100644 --- a/varnish-enterprise/values.yaml +++ b/varnish-enterprise/values.yaml @@ -71,6 +71,11 @@ global: # on a separate cluster. clusterDomain: "cluster.local" + # Defines which repository to use by default + # Options are public-enterprise or private-enterprise + # Check server.image.repository for more information + repoType: "private-enterprise" + serviceAccount: # Specifies whether a service account should be created create: true @@ -543,8 +548,11 @@ server: # Sets the image and tag to use to deploy Varnish Enterprise. # If tag is blank, appVersion is used. + # If repository is "-", check global.repoType + # - private-enterprise: repository will be "quay.io/varnish-software/varnish-plus" + # - public-enterprise: repository will be "varnish/varnish-enterprise" image: - repository: "quay.io/varnish-software/varnish-plus" + repository: "-" pullPolicy: IfNotPresent tag: "" From 85a04f87b02be7e07a07667040ef02b7fb245830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Audun-Marius=20Gangst=C3=B8?= Date: Thu, 12 Feb 2026 11:26:01 +0900 Subject: [PATCH 3/3] Quick fix for the image tag being wrong on the ncsa container --- varnish-enterprise/templates/_helpers.tpl | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/varnish-enterprise/templates/_helpers.tpl b/varnish-enterprise/templates/_helpers.tpl index 532761d..30ce524 100644 --- a/varnish-enterprise/templates/_helpers.tpl +++ b/varnish-enterprise/templates/_helpers.tpl @@ -37,26 +37,24 @@ Sets up the Varnish Enterprise image and its overrides (if any) */}} {{- define "varnish-enterprise.image" -}} {{- $base := .base | default dict -}} -{{- $image := .image | default dict -}} - -{{- $repoType := .Values.global.repoType | default "" -}} -{{- $calculatedRepo := $base.repository -}} - -{{- if eq $repoType "public-enterprise" }} - {{- $calculatedRepo = "varnish/varnish-enterprise" }} -{{- else if eq $repoType "private-enterprise" }} - {{- $calculatedRepo = "quay.io/varnish-software/varnish-plus" }} + {{- $image := .image | default dict -}} + {{- $repoType := .Values.global.repoType | default "" -}} + {{- $calculatedRepo := $base.repository -}} + {{- if eq $repoType "public-enterprise" -}} + {{- $calculatedRepo = "varnish/varnish-enterprise" -}} + {{- else if eq $repoType "private-enterprise" -}} + {{- $calculatedRepo = "quay.io/varnish-software/varnish-plus" -}} {{ end }} image: "{{- if eq $image.repository "-" -}} {{ $calculatedRepo }} {{- else -}} - {{ $image.repository }} y + {{ $image.repository }} {{- end -}} : - {{- if eq $image.tag "-" }} - {{ default .Chart.AppVersion $base.tag }} + {{- if eq $image.tag "-" -}} + {{- default .Chart.AppVersion $base.tag -}} {{- else -}} - {{ default $.Chart.AppVersion $image.tag }} + {{- default $.Chart.AppVersion $image.tag -}} {{- end -}}" imagePullPolicy: {{ if eq $image.pullPolicy "-" }}{{ $base.pullPolicy }}{{ else }}{{ $image.pullPolicy }}{{ end }} {{- end -}}