From 51a990eb5f388358aa7f44fafb976fc7674d232d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Thu, 10 Aug 2023 19:33:49 +0200 Subject: [PATCH] fix: fix for comparing semver for enterprise versions --- charts/kong/CHANGELOG.md | 7 +++++++ charts/kong/Chart.yaml | 2 +- .../test-enterprise-version-3.4.0.0-values.yaml | 14 ++++++++++++++ charts/kong/templates/_helpers.tpl | 16 ++++++++++++++-- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 charts/kong/ci/test-enterprise-version-3.4.0.0-values.yaml diff --git a/charts/kong/CHANGELOG.md b/charts/kong/CHANGELOG.md index 5389b30e1..b400b8f0e 100644 --- a/charts/kong/CHANGELOG.md +++ b/charts/kong/CHANGELOG.md @@ -4,6 +4,13 @@ Nothing yet. +## 2.26.1 + +### Fixed + +* Fix parsing enterprise tags (like e.g. `3.4.0.0`) + [#857](https://github.com/Kong/charts/pull/857) + ## 2.26.0 ### Improvements diff --git a/charts/kong/Chart.yaml b/charts/kong/Chart.yaml index 000c5644d..e3f627d3b 100644 --- a/charts/kong/Chart.yaml +++ b/charts/kong/Chart.yaml @@ -11,7 +11,7 @@ maintainers: name: kong sources: - https://github.com/Kong/charts/tree/main/charts/kong -version: 2.26.0 +version: 2.26.1 appVersion: "3.3" dependencies: - name: postgresql diff --git a/charts/kong/ci/test-enterprise-version-3.4.0.0-values.yaml b/charts/kong/ci/test-enterprise-version-3.4.0.0-values.yaml new file mode 100644 index 000000000..ec09b8d9c --- /dev/null +++ b/charts/kong/ci/test-enterprise-version-3.4.0.0-values.yaml @@ -0,0 +1,14 @@ +ingressController: + enabled: false + +image: + repository: kong/kong-gateway + tag: "3.4.0.0" + +readinessProbe: + httpGet: + path: "/status" + port: status + scheme: HTTP + initialDelaySeconds: 1 + periodSeconds: 1 diff --git a/charts/kong/templates/_helpers.tpl b/charts/kong/templates/_helpers.tpl index 015e99127..c898f5b61 100644 --- a/charts/kong/templates/_helpers.tpl +++ b/charts/kong/templates/_helpers.tpl @@ -786,10 +786,22 @@ The name of the service used for the ingress controller's validation webhook {{/* effectiveVersion takes an image dict from values.yaml. if .effectiveSemver is set, it returns that, else it returns .tag */}} {{- define "kong.effectiveVersion" -}} +{{- /* Because Kong Gateway enterprise uses versions with 4 segments and not 3 */ -}} +{{- /* as semver does, we need to account for that here by extracting */ -}} +{{- /* first 3 segments for comparison */ -}} {{- if .effectiveSemver -}} -{{- .effectiveSemver -}} + {{- if regexMatch "^[0-9]+.[0-9]+.[0-9]+" .effectiveSemver -}} + {{- regexFind "^[0-9]+.[0-9]+.[0-9]+" .effectiveSemver -}} + {{- else -}} + {{- .effectiveSemver -}} + {{- end -}} {{- else -}} -{{- (trimSuffix "-redhat" .tag) -}} + {{- $tag := (trimSuffix "-redhat" .tag) -}} + {{- if regexMatch "^[0-9]+.[0-9]+.[0-9]+" .tag -}} + {{- regexFind "^[0-9]+.[0-9]+.[0-9]+" .tag -}} + {{- else -}} + {{- .tag -}} + {{- end -}} {{- end -}} {{- end -}}