Skip to content

Commit

Permalink
Fixing #28: ingress host names and resource names have different sani…
Browse files Browse the repository at this point in the history
…tization needs
  • Loading branch information
laszlocph committed Aug 27, 2021
1 parent 269ab7e commit e85c443
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 modified charts/cron-job/charts/common-0.1.0.tgz
Binary file not shown.
Binary file modified charts/onechart/charts/common-0.1.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion charts/onechart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 2 additions & 2 deletions charts/onechart/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions charts/onechart/tests/ingress_domain_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -100,4 +100,4 @@ tests:
value:
- hosts:
- chart-example.local
secretName: tls-release-name-chart-example.local
secretName: tls-release-name-chart-example-local

0 comments on commit e85c443

Please sign in to comment.