Skip to content

Commit

Permalink
fix(ingress): switch middleware name and namespace (#636)
Browse files Browse the repository at this point in the history
**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  # <!--(issue)-->

**⚙️ 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?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ 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>
  • Loading branch information
Ornias1993 and stavros-k committed Dec 17, 2023
1 parent 5529a6c commit 1a6bb5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions library/common-test/tests/ingress/traefik_test.yaml
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion library/common/Chart.yaml
Expand Up @@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 16.2.6
version: 16.2.7
Expand Up @@ -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) -}}
Expand Down Expand Up @@ -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 -}}


Expand Down

0 comments on commit 1a6bb5d

Please sign in to comment.