Fixing #28: ingress host names and resource names have different sanitization needs
This commit is contained in:
@@ -6,5 +6,5 @@ Create robustName that can be used as Kubernetes resource name, and as subdomain
|
||||
\W – all but \w .
|
||||
*/}}
|
||||
{{- define "common.robustName" -}}
|
||||
{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }}
|
||||
{{ regexReplaceAll "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -68,5 +68,5 @@ Create robustName that can be used as Kubernetes resource name, and as subdomain
|
||||
\W – all but \w .
|
||||
*/}}
|
||||
{{- define "robustName" -}}
|
||||
{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }}
|
||||
{{ regexReplaceAll "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
@@ -29,11 +29,11 @@ spec:
|
||||
{{- if default false .ingress.tlsEnabled }}
|
||||
tls:
|
||||
- hosts:
|
||||
- {{ template "robustName" .ingress.host | quote }}
|
||||
- {{ .ingress.host | quote }}
|
||||
secretName: {{ printf "tls-%s" $resourceName }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- host: {{ template "robustName" .ingress.host | quote }}
|
||||
- host: {{ .ingress.host | quote }}
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
|
||||
@@ -23,7 +23,7 @@ tests:
|
||||
- backend:
|
||||
serviceName: release-name
|
||||
servicePort: 80
|
||||
- it: Should conform to DNS names
|
||||
- it: Should pass ingress host name as is, user must sanitize it
|
||||
set:
|
||||
ingress:
|
||||
host: feature/my_branch.local
|
||||
@@ -33,12 +33,12 @@ tests:
|
||||
path: spec.tls
|
||||
value:
|
||||
- hosts:
|
||||
- feature-my-branch.local
|
||||
- feature/my_branch.local
|
||||
secretName: tls-release-name
|
||||
- equal:
|
||||
path: spec.rules
|
||||
value:
|
||||
- host: feature-my-branch.local
|
||||
- host: feature/my_branch.local
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
@@ -100,4 +100,4 @@ tests:
|
||||
value:
|
||||
- hosts:
|
||||
- chart-example.local
|
||||
secretName: tls-release-name-chart-example.local
|
||||
secretName: tls-release-name-chart-example-local
|
||||
|
||||
Reference in New Issue
Block a user