mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 00:14:15 -03:00
chore(ingress): default to "/" path if no paths are set and also when path is just empty
This commit is contained in:
@@ -82,6 +82,10 @@ tests:
|
||||
# must be just the fullname
|
||||
name: my-service
|
||||
port: 8080
|
||||
- host: "host-without-explicit-paths"
|
||||
- host: "host-without-explicit-path"
|
||||
paths:
|
||||
- pathPrefix: Exact
|
||||
integrations: *integrations
|
||||
asserts:
|
||||
- documentIndex: &ingressDoc 1
|
||||
@@ -132,6 +136,26 @@ tests:
|
||||
name: test-release-name-common-test
|
||||
port:
|
||||
number: 8080
|
||||
- host: "host-without-explicit-paths"
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: test-release-name-common-test
|
||||
port:
|
||||
number: 80
|
||||
- host: "host-without-explicit-path"
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Exact
|
||||
backend:
|
||||
service:
|
||||
name: test-release-name-common-test
|
||||
port:
|
||||
number: 80
|
||||
|
||||
- it: should pass with ingress created with rules with targetSelector
|
||||
set:
|
||||
|
||||
@@ -70,8 +70,8 @@ tests:
|
||||
integrations: &integrations
|
||||
traefik:
|
||||
enabled: false
|
||||
my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-long-long-long-long-long-long-long-name:
|
||||
enabled: true
|
||||
? my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-long-long-long-long-long-long-long-name
|
||||
: enabled: true
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Name [test-release-name-common-test-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-name-that-is-longer-than-253-characters-my-ingress-super-long-long-long-long-long-long-long-long-name] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters.
|
||||
@@ -287,18 +287,6 @@ tests:
|
||||
- failedTemplate:
|
||||
errorMessage: Ingress - Expected [hosts.host] to not contain [:], but got [test-host:123]
|
||||
|
||||
- it: should fail without paths
|
||||
set:
|
||||
ingress:
|
||||
my-ingress:
|
||||
enabled: true
|
||||
primary: true
|
||||
hosts:
|
||||
- host: test-host
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Ingress - Expected non-empty [hosts.paths]
|
||||
|
||||
- it: should fail with paths not a slice
|
||||
set:
|
||||
ingress:
|
||||
@@ -521,7 +509,7 @@ tests:
|
||||
hosts: *hosts
|
||||
tls:
|
||||
- hosts:
|
||||
- ""
|
||||
- ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Ingress - Expected non-empty entry in [tls.hosts]
|
||||
@@ -536,7 +524,7 @@ tests:
|
||||
hosts: *hosts
|
||||
tls:
|
||||
- hosts:
|
||||
- https://test-host
|
||||
- https://test-host
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Ingress - Expected entry in [tls.hosts] to not start with [https://], but got [https://test-host]
|
||||
@@ -551,7 +539,7 @@ tests:
|
||||
hosts: *hosts
|
||||
tls:
|
||||
- hosts:
|
||||
- http://test-host
|
||||
- http://test-host
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Ingress - Expected entry in [tls.hosts] to not start with [http://], but got [http://test-host]
|
||||
@@ -566,7 +554,7 @@ tests:
|
||||
hosts: *hosts
|
||||
tls:
|
||||
- hosts:
|
||||
- test-host:123
|
||||
- test-host:123
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Ingress - Expected entry in [tls.hosts] to not contain [:], but got [test-host:123]
|
||||
@@ -581,7 +569,7 @@ tests:
|
||||
hosts: *hosts
|
||||
tls:
|
||||
- hosts:
|
||||
- test-host
|
||||
- test-host
|
||||
secretName: test-secret
|
||||
clusterCertificate: some-cert
|
||||
asserts:
|
||||
|
||||
@@ -60,11 +60,14 @@ spec:
|
||||
- host: {{ (tpl $h.host $rootCtx) | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- if not $h.paths -}} {{/* If no paths given, default to "/" */}}
|
||||
{{- $_ := set $h "paths" (dict "path" "/") -}}
|
||||
{{- end -}}
|
||||
{{- range $p := $h.paths -}}
|
||||
{{- $svcData = (include "tc.v1.common.lib.ingress.backend.data" (dict
|
||||
"rootCtx" $rootCtx "svcData" $svcData "override" $p.overrideService)) | fromYaml
|
||||
}}
|
||||
- path: {{ tpl $p.path $rootCtx }}
|
||||
- path: {{ (tpl $p.path $rootCtx) | default "/" }}
|
||||
pathType: {{ tpl ($p.pathType | default "Prefix") $rootCtx }}
|
||||
backend:
|
||||
service:
|
||||
|
||||
@@ -62,11 +62,7 @@ objectData:
|
||||
{{- fail (printf "Ingress - Expected [hosts.host] to not contain [:], but got [%s]" $host) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $h.paths -}}
|
||||
{{- fail "Ingress - Expected non-empty [hosts.paths]" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (kindIs "slice" $h.paths) -}}
|
||||
{{- if and $h.paths (not (kindIs "slice" $h.paths)) -}}
|
||||
{{- fail (printf "Ingress - Expected [hosts.paths] to be a [slice], but got [%s]" (kindOf $h.paths)) -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -84,7 +80,7 @@ objectData:
|
||||
{{- $path := tpl $p.path $rootCtx -}}
|
||||
{{- $prefixSlashTypes := (list "Prefix" "Exact") -}}
|
||||
{{- if (mustHas $pathType $prefixSlashTypes) -}}
|
||||
{{- if not (hasPrefix "/" $path) -}}
|
||||
{{- if and $path (not (hasPrefix "/" $path)) -}}
|
||||
{{- fail (printf "Ingress - Expected [hosts.paths.path] to start with [/], but got [%s]" $path) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user