From 53d1f59dfd477d20ecfa3af258421319855dd4f9 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Fri, 9 Jun 2023 09:23:36 +0300 Subject: [PATCH] fix(ingress): fix ingress and chartcontext namespace (#461) 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: Kjeld Schouten --- library/common/templates/class/_ingress.tpl | 10 +++++++--- .../common/templates/lib/util/_chartcontext.tpl | 14 ++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/library/common/templates/class/_ingress.tpl b/library/common/templates/class/_ingress.tpl index 5082c59d..9e84b064 100644 --- a/library/common/templates/class/_ingress.tpl +++ b/library/common/templates/class/_ingress.tpl @@ -17,7 +17,6 @@ within the common library. {{- $ingressName = $values.name -}} - {{/* Get the name of the primary service, if any */}} {{- $primaryServiceName := (include "tc.v1.common.lib.util.service.primary" (dict "services" .Values.service "root" .)) -}} {{/* Get service values of the primary service, if any */}} @@ -32,12 +31,17 @@ within the common library. {{- $mddwrNamespace := "tc-system" -}} {{- if $.Values.operator.traefik -}} {{- if $.Values.operator.traefik.namespace -}} - {{- $mddwrNamespace := (printf "ix-%s" $values.ingressClassName) -}} + {{- $mddwrNamespace = $.Values.operator.traefik.namespace -}} {{- end -}} {{- end -}} {{- if $values.ingressClassName -}} - {{- $mddwrNamespace = $values.ingressClassName -}} + + {{- if $.Values.global.ixChartContext -}} + {{- $mddwrNamespace = (printf "ix-%s" $values.ingressClassName) -}} + {{- else -}} + {{- $mddwrNamespace = $values.ingressClassName -}} + {{- end -}} {{- end -}} {{- $fixedMiddlewares := "" -}} diff --git a/library/common/templates/lib/util/_chartcontext.tpl b/library/common/templates/lib/util/_chartcontext.tpl index dd05c328..214d7309 100644 --- a/library/common/templates/lib/util/_chartcontext.tpl +++ b/library/common/templates/lib/util/_chartcontext.tpl @@ -43,20 +43,22 @@ {{- end -}} {{/* Get the port for the ingress entrypoint */}} - {{- $namespace := "tc-system" -}} {{- if $.Values.operator.traefik -}} {{- if $.Values.operator.traefik.namespace -}} - {{- $namespace := $.Values.operator.traefik.namespace -}} + {{- $namespace = $.Values.operator.traefik.namespace -}} {{- end -}} {{- end -}} - {{- if $selectedIngress.ingressClassName }} - {{- $namespace = $selectedIngress.ingressClassName -}} - {{- end -}} {{- if $selectedIngress.ingressClassName -}} - {{- $namespace = (printf "ix-%s" $selectedIngress.ingressClassName) -}} + {{- if $.Values.global.ixChartContext -}} + {{- $namespace = (printf "ix-%s" $selectedIngress.ingressClassName) -}} + {{- else -}} + {{- $namespace = $selectedIngress.ingressClassName -}} + {{- end -}} + {{- end -}} + {{- $traefikportalhook := lookup "v1" "ConfigMap" $namespace "portalhook" -}} {{- $entrypoint := "websecure" -}} {{- if $selectedIngress.entrypoint -}}