Merge pull request #29 from gimlet-io/fix-robustname

Fixing #28: ingress host names and resource names have different sani…
This commit is contained in:
Laszlo Fogas
2021-08-27 09:06:37 +02:00
committed by GitHub
6 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -6,5 +6,5 @@ Create robustName that can be used as Kubernetes resource name, and as subdomain
\W all but \w . \W all but \w .
*/}} */}}
{{- define "common.robustName" -}} {{- define "common.robustName" -}}
{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }} {{ regexReplaceAll "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }}
{{- end }} {{- end }}
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -68,5 +68,5 @@ Create robustName that can be used as Kubernetes resource name, and as subdomain
\W all but \w . \W all but \w .
*/}} */}}
{{- define "robustName" -}} {{- define "robustName" -}}
{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }} {{ regexReplaceAll "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }}
{{- end }} {{- end }}
+2 -2
View File
@@ -29,11 +29,11 @@ spec:
{{- if default false .ingress.tlsEnabled }} {{- if default false .ingress.tlsEnabled }}
tls: tls:
- hosts: - hosts:
- {{ template "robustName" .ingress.host | quote }} - {{ .ingress.host | quote }}
secretName: {{ printf "tls-%s" $resourceName }} secretName: {{ printf "tls-%s" $resourceName }}
{{- end }} {{- end }}
rules: rules:
- host: {{ template "robustName" .ingress.host | quote }} - host: {{ .ingress.host | quote }}
http: http:
paths: paths:
- backend: - backend:
@@ -23,7 +23,7 @@ tests:
- backend: - backend:
serviceName: release-name serviceName: release-name
servicePort: 80 servicePort: 80
- it: Should conform to DNS names - it: Should pass ingress host name as is, user must sanitize it
set: set:
ingress: ingress:
host: feature/my_branch.local host: feature/my_branch.local
@@ -33,12 +33,12 @@ tests:
path: spec.tls path: spec.tls
value: value:
- hosts: - hosts:
- feature-my-branch.local - feature/my_branch.local
secretName: tls-release-name secretName: tls-release-name
- equal: - equal:
path: spec.rules path: spec.rules
value: value:
- host: feature-my-branch.local - host: feature/my_branch.local
http: http:
paths: paths:
- backend: - backend:
@@ -100,4 +100,4 @@ tests:
value: value:
- hosts: - hosts:
- chart-example.local - chart-example.local
secretName: tls-release-name-chart-example.local secretName: tls-release-name-chart-example-local