Fixing robustName to allow '.'
This commit is contained in:
@@ -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 "\\W+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" }}
|
{{ regexReplaceAll "[^0-9A-Za-z_\\.]+" . "-" | replace "_" "-" | lower | trunc 63 | trimSuffix "-" | trimPrefix "-" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{{- $labels := include "helm-chart.labels" . -}}
|
{{- $labels := include "helm-chart.labels" . -}}
|
||||||
|
|
||||||
{{- with .Values.ingress -}}
|
{{- with .Values.ingress -}}
|
||||||
|
{{- $robustName := include "robustName" $.Release.Name -}}
|
||||||
{{- if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion -}}
|
{{- if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion -}}
|
||||||
apiVersion: networking.k8s.io/v1beta1
|
apiVersion: networking.k8s.io/v1beta1
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
@@ -8,7 +9,7 @@ apiVersion: extensions/v1beta1
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ template "robustName" $.Release.Name }}
|
name: {{ $robustName }}
|
||||||
namespace: {{ $.Release.Namespace }}
|
namespace: {{ $.Release.Namespace }}
|
||||||
labels:
|
labels:
|
||||||
{{- $labels | nindent 4 }}
|
{{- $labels | nindent 4 }}
|
||||||
@@ -20,8 +21,8 @@ spec:
|
|||||||
{{- if default false .tlsEnabled }}
|
{{- if default false .tlsEnabled }}
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- {{ .host | quote }}
|
- {{ template "robustName" .host | quote }}
|
||||||
secretName: {{ printf "tls-%s" $.Release.Name }}
|
secretName: {{ printf "tls-%s" $robustName }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
rules:
|
rules:
|
||||||
- host: {{ template "robustName" .host | quote }}
|
- host: {{ template "robustName" .host | quote }}
|
||||||
|
|||||||
@@ -13,7 +13,37 @@ tests:
|
|||||||
value:
|
value:
|
||||||
- hosts:
|
- hosts:
|
||||||
- chart-example.local
|
- chart-example.local
|
||||||
secretName: tls-RELEASE-NAME
|
secretName: tls-release-name
|
||||||
|
- equal:
|
||||||
|
path: spec.rules
|
||||||
|
value:
|
||||||
|
- host: chart-example.local
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- backend:
|
||||||
|
serviceName: release-name
|
||||||
|
servicePort: 80
|
||||||
|
- it: Should conform to DNS names
|
||||||
|
set:
|
||||||
|
ingress:
|
||||||
|
host: feature/my_branch.local
|
||||||
|
tlsEnabled: true
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.tls
|
||||||
|
value:
|
||||||
|
- hosts:
|
||||||
|
- feature-my-branch.local
|
||||||
|
secretName: tls-release-name
|
||||||
|
- equal:
|
||||||
|
path: spec.rules
|
||||||
|
value:
|
||||||
|
- host: feature-my-branch.local
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- backend:
|
||||||
|
serviceName: release-name
|
||||||
|
servicePort: 80
|
||||||
- it: Should set Ingress annotation
|
- it: Should set Ingress annotation
|
||||||
set:
|
set:
|
||||||
ingress:
|
ingress:
|
||||||
|
|||||||
@@ -5,3 +5,7 @@ volumes:
|
|||||||
path: /data
|
path: /data
|
||||||
size: 1Gi
|
size: 1Gi
|
||||||
storageClass: local-path
|
storageClass: local-path
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
host: chart-example.local
|
||||||
|
tlsEnabled: true
|
||||||
|
|||||||
Reference in New Issue
Block a user