From 9bda317a34a967471ce7ebe4fa7910e18bf05e70 Mon Sep 17 00:00:00 2001 From: "V. Klopfenstein" <13659371+ThisIsntTheWay@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:54:55 +0100 Subject: [PATCH] Typos, handle collabora --- pkg/comp-functions/functions/common/util.go | 2 +- .../functions/vshnkeycloak/ingress.go | 4 ++-- .../functions/vshnkeycloak/ingress_test.go | 2 +- .../functions/vshnnextcloud/collabora.go | 16 +++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/comp-functions/functions/common/util.go b/pkg/comp-functions/functions/common/util.go index b180a41725..e46803bd83 100644 --- a/pkg/comp-functions/functions/common/util.go +++ b/pkg/comp-functions/functions/common/util.go @@ -41,5 +41,5 @@ func IsSingleSubdomainOfRefDomain(fqdn string, reference string) bool { } noSuffix, _ := strings.CutSuffix(fqdn, reference) - return len(strings.Split(noSuffix, ".")) == 2 // Handles prefixed dot of reference domain< + return len(strings.Split(noSuffix, ".")) == 2 // Handles prefixed dot of reference domain } diff --git a/pkg/comp-functions/functions/vshnkeycloak/ingress.go b/pkg/comp-functions/functions/vshnkeycloak/ingress.go index 24b8ef5029..cb4a429a15 100644 --- a/pkg/comp-functions/functions/vshnkeycloak/ingress.go +++ b/pkg/comp-functions/functions/vshnkeycloak/ingress.go @@ -34,7 +34,7 @@ func AddIngress(_ context.Context, comp *vshnv1.VSHNKeycloak, svc *runtime.Servi } svc.Log.Info("Enable ingress for release") - enableIngresValues(svc, comp, values) + enableIngressValues(svc, comp, values) release := &xhelmv1.Release{} err = svc.GetDesiredComposedResourceByName(release, comp.GetName()+"-release") @@ -57,7 +57,7 @@ func AddIngress(_ context.Context, comp *vshnv1.VSHNKeycloak, svc *runtime.Servi return nil } -func enableIngresValues(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNKeycloak, values map[string]any) { +func enableIngressValues(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNKeycloak, values map[string]any) { fqdn := comp.Spec.Parameters.Service.FQDN relPath := `'{{ tpl .Values.http.relativePath $ | trimSuffix " / " }}/'` diff --git a/pkg/comp-functions/functions/vshnkeycloak/ingress_test.go b/pkg/comp-functions/functions/vshnkeycloak/ingress_test.go index 43565bc9ad..f76a6a1c71 100644 --- a/pkg/comp-functions/functions/vshnkeycloak/ingress_test.go +++ b/pkg/comp-functions/functions/vshnkeycloak/ingress_test.go @@ -104,7 +104,7 @@ func TestEnableIngresValues(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { svc := commontest.LoadRuntimeFromFile(t, "vshnkeycloak/01_default.yaml") - enableIngresValues(svc, tt.args.comp, tt.args.values) + enableIngressValues(svc, tt.args.comp, tt.args.values) assert.Equal(t, tt.want, tt.args.values) }) } diff --git a/pkg/comp-functions/functions/vshnnextcloud/collabora.go b/pkg/comp-functions/functions/vshnnextcloud/collabora.go index 2c1714e8f1..8b15083740 100644 --- a/pkg/comp-functions/functions/vshnnextcloud/collabora.go +++ b/pkg/comp-functions/functions/vshnnextcloud/collabora.go @@ -332,6 +332,13 @@ func AddCollaboraIngress(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceRuntime annotations["haproxy.router.openshift.io/hsts_header"] = "max-age=31536000;preload" } + fqdn := comp.Spec.Parameters.Service.Collabora.FQDN + tlsConfig := networkingv1.IngressTLS{} + if !common.IsSingleSubdomainOfRefDomain(fqdn, svc.Config.Data["ocpDefaultAppsDomain"]) { + tlsConfig.Hosts = []string{fqdn} + tlsConfig.SecretName = comp.GetName() + "-collabora-code-ingress-tls" + } + ingress := &networkingv1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: comp.GetName() + "-collabora-code", @@ -344,7 +351,7 @@ func AddCollaboraIngress(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceRuntime Spec: networkingv1.IngressSpec{ Rules: []networkingv1.IngressRule{ { - Host: comp.Spec.Parameters.Service.Collabora.FQDN, + Host: fqdn, IngressRuleValue: networkingv1.IngressRuleValue{ HTTP: &networkingv1.HTTPIngressRuleValue{ Paths: []networkingv1.HTTPIngressPath{ @@ -365,12 +372,7 @@ func AddCollaboraIngress(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceRuntime }, }, }, - TLS: []networkingv1.IngressTLS{ - { - Hosts: []string{comp.Spec.Parameters.Service.Collabora.FQDN}, - SecretName: comp.GetName() + "-collabora-code-ingress-tls", - }, - }, + TLS: []networkingv1.IngressTLS{tlsConfig}, }, }