From 050930771b06fa7793601e60aa6b91891c7acf4a Mon Sep 17 00:00:00 2001 From: carl hedgren Date: Thu, 7 Nov 2024 15:40:49 +0100 Subject: [PATCH] Differentiate application for debug Co-Authored-By: sindrerh2 Co-Authored-By: Youssef Bel Mekki <38552193+ybelMekk@users.noreply.github.com> --- pkg/resourcecreator/ingress/ingress.go | 11 ++++++----- pkg/resourcecreator/testdata/ingress_redirect.yaml | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/resourcecreator/ingress/ingress.go b/pkg/resourcecreator/ingress/ingress.go index 949982e4..10fa7c8b 100644 --- a/pkg/resourcecreator/ingress/ingress.go +++ b/pkg/resourcecreator/ingress/ingress.go @@ -181,21 +181,22 @@ func nginxIngresses(source Source, cfg Config) ([]*networkingv1.Ingress, error) if redirects != nil && len(redirects) > 0 { for _, redirect := range redirects { - parsedUrl, err := parseIngress(string(redirect.To)) + parsedRedirectUrl, err := parseIngress(string(redirect.To)) if err != nil { return nil, err } for _, ing := range ingresses { for _, rule := range ing.Spec.Rules { // found the ingress that matches the redirect - if rule.Host == parsedUrl.Host { - r := ingressRule(source.GetName(), parsedUrl) + if rule.Host == parsedRedirectUrl.Host { + r := ingressRule(source.GetName(), parsedRedirectUrl) ingressClass := util.ResolveIngressClass(rule.Host, cfg.GetGatewayMappings()) - rdIngresses, err := getIngress(source, cfg, r, ingressClass, string(redirect.From)) + rdIngress, err := getIngress(source, cfg, r, ingressClass, string(redirect.From)) if err != nil { return nil, err } - redirectIngresses[*ingressClass] = rdIngresses + rdIngress.Name = "foo" + redirectIngresses[*ingressClass] = rdIngress } } } diff --git a/pkg/resourcecreator/testdata/ingress_redirect.yaml b/pkg/resourcecreator/testdata/ingress_redirect.yaml index b644f4a8..164a3e29 100644 --- a/pkg/resourcecreator/testdata/ingress_redirect.yaml +++ b/pkg/resourcecreator/testdata/ingress_redirect.yaml @@ -13,7 +13,7 @@ input: kind: Application apiVersion: nais.io/v1alpha1 metadata: - name: myapplication + name: myapplicationredirect namespace: mynamespace uid: "123456" spec: @@ -45,7 +45,7 @@ tests: paths: - backend: service: - name: myapplication + name: myapplicationredirect port: number: 80 path: / @@ -76,7 +76,7 @@ tests: - operation: CreateOrUpdate apiVersion: networking.k8s.io/v1 kind: Ingress - name: myapplication-nais-ingress-941e7d93-THIS-ONE-FAILS-ON-PURPOSE-SHOULD-BE-THE-REDIRECT-INGRESS + name: foo match: - type: subset name: "redirect ingress for myapp"