From 1a6bb5d9b9ed9d8fe96ac71231345cc5166f8fbe Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 17 Dec 2023 12:31:15 +0100 Subject: [PATCH] fix(ingress): switch middleware name and namespace (#636) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- .../common-test/tests/ingress/traefik_test.yaml | 14 +++++++------- library/common/Chart.yaml | 2 +- .../lib/ingress/integrations/_traefik.tpl | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/common-test/tests/ingress/traefik_test.yaml b/library/common-test/tests/ingress/traefik_test.yaml index 9368be487..3fa6b531d 100644 --- a/library/common-test/tests/ingress/traefik_test.yaml +++ b/library/common-test/tests/ingress/traefik_test.yaml @@ -47,7 +47,7 @@ tests: path: metadata.annotations value: traefik.ingress.kubernetes.io/router.entrypoints: websecure - traefik.ingress.kubernetes.io/router.middlewares: chain-basic-test-release-namespace@kubernetescrd + traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd - documentIndex: *ingressDoc equal: path: metadata.namespace @@ -114,7 +114,7 @@ tests: path: metadata.annotations value: traefik.ingress.kubernetes.io/router.entrypoints: websecure - traefik.ingress.kubernetes.io/router.middlewares: tc-opencors-chain-test-release-namespace@kubernetescrd + traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-tc-opencors-chain@kubernetescrd - it: should replace global fixedMiddlewares when allowCors true set: @@ -150,7 +150,7 @@ tests: path: metadata.annotations value: traefik.ingress.kubernetes.io/router.entrypoints: websecure - traefik.ingress.kubernetes.io/router.middlewares: tc-opencors-chain-test-release-namespace@kubernetescrd + traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-tc-opencors-chain@kubernetescrd - it: should replace global fixedMiddlewares when local fixedMiddlewares is defined set: @@ -181,7 +181,7 @@ tests: path: metadata.annotations value: traefik.ingress.kubernetes.io/router.entrypoints: websecure - traefik.ingress.kubernetes.io/router.middlewares: some-fixed-middleware-test-release-namespace@kubernetescrd + traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-some-fixed-middleware@kubernetescrd - it: should override default entrypoint(s) set: @@ -212,7 +212,7 @@ tests: path: metadata.annotations value: traefik.ingress.kubernetes.io/router.entrypoints: web,websecure - traefik.ingress.kubernetes.io/router.middlewares: chain-basic-test-release-namespace@kubernetescrd + traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd - it: should not contain fixed middlewares when global is disabled set: @@ -299,7 +299,7 @@ tests: path: metadata.annotations value: traefik.ingress.kubernetes.io/router.entrypoints: websecure - traefik.ingress.kubernetes.io/router.middlewares: chain-basic-test-release-namespace@kubernetescrd,some-middleware-test-release-namespace@kubernetescrd,some-other-middleware-test-release-namespace@kubernetescrd + traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd,test-release-namespace-some-middleware@kubernetescrd,test-release-namespace-some-other-middleware@kubernetescrd # Failures - it: should fail with entrypoint not a slice @@ -371,7 +371,7 @@ tests: hosts: *hosts asserts: - failedTemplate: - errorMessage: Ingress - Combined traefik middlewares contain duplicates [chain-basic-test-release-namespace, chain-basic-test-release-namespace] + errorMessage: Ingress - Combined traefik middlewares contain duplicates [test-release-namespace-chain-basic, test-release-namespace-chain-basic] - it: should fail with duplicate entrypoints set: diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index b3064dbe6..81999d4f1 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 16.2.6 +version: 16.2.7 diff --git a/library/common/templates/lib/ingress/integrations/_traefik.tpl b/library/common/templates/lib/ingress/integrations/_traefik.tpl index 829fc8c27..d3f07c243 100644 --- a/library/common/templates/lib/ingress/integrations/_traefik.tpl +++ b/library/common/templates/lib/ingress/integrations/_traefik.tpl @@ -54,7 +54,7 @@ {{/* Only used for better error */}} {{- $middlewareNameList := list -}} {{- range $mid := $middlewares -}} - {{- $middlewareNameList = mustAppend $middlewareNameList (printf "%s-%s" $mid.name $mid.namespace) -}} + {{- $middlewareNameList = mustAppend $middlewareNameList (printf "%s-%s" $mid.namespace $mid.name ) -}} {{- end -}} {{- if not (deepEqual (mustUniq $middlewares) $middlewares) -}} @@ -116,7 +116,7 @@ {{- end -}} {{/* Format middleware */}} - {{- $formattedMiddlewares = mustAppend $formattedMiddlewares (printf "%s-%s@kubernetescrd" $mid.name $midNamespace) -}} + {{- $formattedMiddlewares = mustAppend $formattedMiddlewares (printf "%s-%s@kubernetescrd" $midNamespace $mid.name ) -}} {{- end -}}