From d24fbe0fde7ae6a74cfbd1b1aa276735cdb60e04 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Fri, 8 Dec 2023 18:53:10 +0200 Subject: [PATCH] fix last tests --- .../templates/lib/util/_chartcontext.tpl | 24 +++++++++++++++---- .../templates/lib/util/_primary_ingress.tpl | 12 ++++++---- .../templates/lib/util/_primary_port.tpl | 12 ++++++---- .../templates/lib/util/_primary_service.tpl | 12 ++++++---- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/library/common/templates/lib/util/_chartcontext.tpl b/library/common/templates/lib/util/_chartcontext.tpl index 63a96aa8..cb29ea72 100644 --- a/library/common/templates/lib/util/_chartcontext.tpl +++ b/library/common/templates/lib/util/_chartcontext.tpl @@ -64,10 +64,19 @@ {{- end -}} {{- with $selectedIngress -}} - {{- $firstHost := ((.hosts | default list) | mustFirst) -}} + {{- $firstHost := list -}} + {{- if (kindIs "slice" .hosts) -}} + {{- $firstHost = ((.hosts | default list) | mustFirst) -}} + {{- end -}} {{- if $firstHost -}} - {{- $host = tpl $firstHost.host $rootCtx -}} - {{- $firstPath := (($firstHost.paths | default list) | mustFirst) -}} + {{- if $firstHost.host -}} + {{- $host = tpl $firstHost.host $rootCtx -}} + {{- end -}} + + {{- $firstPath := list -}} + {{- if (kindIs "slice" $firstHost.paths) -}} + {{- $firstPath = (($firstHost.paths | default list) | mustFirst) -}} + {{- end -}} {{- if $firstPath -}} {{- $path = $firstPath.path -}} {{- end -}} @@ -120,7 +129,10 @@ {{- $primaryPort := dict -}} {{- if $selectedService -}} {{- $primaryPortName := include "tc.v1.common.lib.util.service.ports.primary" (dict "rootCtx" $rootCtx "svcValues" $selectedService) -}} - {{- $selectedPort := (get $selectedService.ports $primaryPortName) -}} + {{- $selectedPort := dict -}} + {{- if $selectedService.ports -}} {{/* eg, ExternalName does not require ports */}} + {{- $selectedPort = (get $selectedService.ports $primaryPortName) -}} + {{- end -}} {{- with $objectData.targetSelector -}} {{- if .port -}} @@ -133,7 +145,9 @@ {{- if not $selectedPort -}} {{- $portName := ($selectedService.ports | keys | sortAlpha | mustFirst) -}} - {{- $selectedPort = (get $selectedService.ports $portName) -}} + {{- if $selectedService.ports -}} {{/* eg, ExternalName does not require ports */}} + {{- $selectedPort = (get $selectedService.ports $portName) -}} + {{- end -}} {{- end -}} {{- $port = tpl ($selectedPort.port | toString) $rootCtx -}} diff --git a/library/common/templates/lib/util/_primary_ingress.tpl b/library/common/templates/lib/util/_primary_ingress.tpl index 8a1d1813..ff0cd52b 100644 --- a/library/common/templates/lib/util/_primary_ingress.tpl +++ b/library/common/templates/lib/util/_primary_ingress.tpl @@ -4,10 +4,14 @@ {{- $result := "" -}} {{- range $name, $ingress := $rootCtx.Values.ingress -}} - {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict - "rootCtx" $rootCtx "objectData" $ingress - "name" $name "caller" "Primary Ingress Util" - "key" "ingress")) -}} + {{- $enabled := "false" -}} + + {{- if not (kindIs "invalid" $ingress.enabled) -}} + {{- $enabled = (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $rootCtx "objectData" $ingress + "name" $name "caller" "Primary Ingress Util" + "key" "ingress")) -}} + {{- end -}} {{- if eq $enabled "true" -}} {{- if $ingress.primary -}} diff --git a/library/common/templates/lib/util/_primary_port.tpl b/library/common/templates/lib/util/_primary_port.tpl index 6ca104fb..62e42b81 100644 --- a/library/common/templates/lib/util/_primary_port.tpl +++ b/library/common/templates/lib/util/_primary_port.tpl @@ -6,10 +6,14 @@ {{- $result := "" -}} {{- range $name, $port := $svcValues.ports -}} - {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict - "rootCtx" $rootCtx "objectData" $port - "name" $name "caller" "Primary Port Util" - "key" ".ports.$portname.enabled")) -}} + {{- $enabled := "false" -}} + + {{- if not (kindIs "invalid" $port.enabled) -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $rootCtx "objectData" $port + "name" $name "caller" "Primary Port Util" + "key" ".ports.$portname.enabled")) -}} + {{- end -}} {{- if eq $enabled "true" -}} {{- if $port.primary -}} diff --git a/library/common/templates/lib/util/_primary_service.tpl b/library/common/templates/lib/util/_primary_service.tpl index cae23d11..30b11500 100644 --- a/library/common/templates/lib/util/_primary_service.tpl +++ b/library/common/templates/lib/util/_primary_service.tpl @@ -4,10 +4,14 @@ {{- $result := "" -}} {{- range $name, $service := $rootCtx.Values.service -}} - {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict - "rootCtx" $rootCtx "objectData" $service - "name" $name "caller" "Primary service Util" - "key" "service")) -}} + {{- $enabled := "false" -}} + + {{- if not (kindIs "invalid" $service.enabled) -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $rootCtx "objectData" $service + "name" $name "caller" "Primary service Util" + "key" "service")) -}} + {{- end -}} {{- if eq $enabled "true" -}} {{- if $service.primary -}}