From d4cab24a3dc13730c55cea4617987c20462126f9 Mon Sep 17 00:00:00 2001 From: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:08:04 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20improve=20error=20message?= =?UTF-8?q?=20on=20additional=20service=20without=20ports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- traefik/templates/service.yaml | 6 ++---- traefik/tests/service-config-custom_test.yaml | 2 +- traefik/tests/service-config_test.yaml | 15 +-------------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/traefik/templates/service.yaml b/traefik/templates/service.yaml index e74e81fc0..d63113c85 100644 --- a/traefik/templates/service.yaml +++ b/traefik/templates/service.yaml @@ -11,13 +11,11 @@ {{- $exposedPorts := false -}} {{- range $portName, $config := $.Values.ports -}} {{- if $config -}} - {{- if $config.http3 -}} - {{- if $config.http3.enabled -}} + {{- if ($config.http3).enabled -}} {{- if (not $config.tls.enabled) -}} {{- fail "ERROR: You cannot enable http3 without enabling tls" -}} {{- end -}} {{- end -}} - {{- end -}} {{- if eq (toString $config.protocol) "UDP" -}} {{ $_ := set $udpPorts $portName $config -}} {{- end -}} @@ -31,7 +29,7 @@ {{- end -}} {{- if (eq $exposedPorts false) -}} - {{- fail "You need to expose at least one port or set enabled=false to service" -}} + {{- fail (printf "ERROR: Cannot create Service %s without ports" $fullname) -}} {{- end -}} {{- if and $exposedPorts (or $tcpPorts $service.single) }} diff --git a/traefik/tests/service-config-custom_test.yaml b/traefik/tests/service-config-custom_test.yaml index 9e6581183..46a0541f0 100644 --- a/traefik/tests/service-config-custom_test.yaml +++ b/traefik/tests/service-config-custom_test.yaml @@ -46,7 +46,7 @@ tests: internal: false asserts: - failedTemplate: - errorMessage: "You need to expose at least one port or set enabled=false to service" + errorMessage: "ERROR: Cannot create Service RELEASE-NAME-traefik-internal without ports" - it: should have customized annotations when specified via values set: service: diff --git a/traefik/tests/service-config_test.yaml b/traefik/tests/service-config_test.yaml index e7e2728d8..7b0a5f312 100644 --- a/traefik/tests/service-config_test.yaml +++ b/traefik/tests/service-config_test.yaml @@ -24,7 +24,7 @@ tests: default: false asserts: - failedTemplate: - errorMessage: "You need to expose at least one port or set enabled=false to service" + errorMessage: "ERROR: Cannot create Service RELEASE-NAME-traefik without ports" - it: should be a type LoadBalancer by default asserts: - equal: @@ -273,19 +273,6 @@ tests: - equal: path: spec.ports[2].protocol value: UDP - - it: should fail when there is no exposed port - set: - ports: - web: - expose: - default: false - websecure: - expose: - default: false - asserts: - - failedTemplate: - errorMessage: "You need to expose at least one port or set enabled=false to service" - documentIndex: 1 - it: should not be possible to use http3 without enabling tls set: ports: