Skip to content

Commit

Permalink
fix: 🐛 improve error message on additional service without ports
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur authored Jun 27, 2024
1 parent 0449b0b commit d4cab24
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
6 changes: 2 additions & 4 deletions traefik/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -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) }}
Expand Down
2 changes: 1 addition & 1 deletion traefik/tests/service-config-custom_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 1 addition & 14 deletions traefik/tests/service-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d4cab24

Please sign in to comment.