Skip to content

Commit

Permalink
feat(chart): templating in name(Override) (#2107)
Browse files Browse the repository at this point in the history
Co-authored-by: Viet Nguyen Duc <[email protected]>
[skip ci]
  • Loading branch information
Opvolger authored Jan 23, 2024
1 parent 84ac1f8 commit 3be1d42
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 40 deletions.
34 changes: 17 additions & 17 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,70 +43,70 @@ helm.sh/chart: {{ include "seleniumGrid.chart" . }}
Selenium Hub fullname
*/}}
{{- define "seleniumGrid.hub.fullname" -}}
{{- default "selenium-hub" .Values.hub.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-hub" .Values.hub.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Event bus fullname
*/}}
{{- define "seleniumGrid.eventBus.fullname" -}}
{{- default "selenium-event-bus" .Values.components.eventBus.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-event-bus" .Values.components.eventBus.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Router fullname
*/}}
{{- define "seleniumGrid.router.fullname" -}}
{{- default "selenium-router" .Values.components.router.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-router" .Values.components.router.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Distributor fullname
*/}}
{{- define "seleniumGrid.distributor.fullname" -}}
{{- default "selenium-distributor" .Values.components.distributor.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-distributor" .Values.components.distributor.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
SessionMap fullname
*/}}
{{- define "seleniumGrid.sessionMap.fullname" -}}
{{- default "selenium-session-map" .Values.components.sessionMap.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-session-map" .Values.components.sessionMap.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
SessionQueue fullname
*/}}
{{- define "seleniumGrid.sessionQueue.fullname" -}}
{{- default "selenium-session-queue" .Values.components.sessionQueue.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-session-queue" .Values.components.sessionQueue.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Chrome node fullname
*/}}
{{- define "seleniumGrid.chromeNode.fullname" -}}
{{- default "selenium-chrome-node" .Values.chromeNode.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-chrome-node" .Values.chromeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Firefox node fullname
*/}}
{{- define "seleniumGrid.firefoxNode.fullname" -}}
{{- default "selenium-firefox-node" .Values.firefoxNode.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-firefox-node" .Values.firefoxNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Edge node fullname
*/}}
{{- define "seleniumGrid.edgeNode.fullname" -}}
{{- default "selenium-edge-node" .Values.edgeNode.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-edge-node" .Values.edgeNode.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Ingress fullname
*/}}
{{- define "seleniumGrid.ingress.fullname" -}}
{{- default "selenium-ingress" .Values.ingress.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-ingress" .Values.ingress.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand Down Expand Up @@ -170,7 +170,7 @@ Get probe settings
Secret TLS fullname
*/}}
{{- define "seleniumGrid.tls.fullname" -}}
{{- default "selenium-tls-secret" .Values.tls.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- ( tpl (default "selenium-tls-secret" .Values.tls.nameOverride) $ )| trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand All @@ -197,7 +197,7 @@ Get default certificate file name in chart
Common secrets cross components
*/}}
{{- define "seleniumGrid.common.secrets" -}}
{{- default "selenium-secrets" .Values.secrets.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-secrets" .Values.secrets.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "seleniumGrid.ingress.nginx.annotations.default" -}}
Expand Down Expand Up @@ -231,14 +231,14 @@ nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
Service Account fullname
*/}}
{{- define "seleniumGrid.serviceAccount.fullname" -}}
{{- .Values.serviceAccount.name | default "selenium-serviceaccount" | trunc 63 | trimSuffix "-" -}}
{{- tpl (.Values.serviceAccount.name | default "selenium-serviceaccount") $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Video ConfigMap fullname
*/}}
{{- define "seleniumGrid.video.fullname" -}}
{{- default "selenium-video" .Values.videoRecorder.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- tpl (default "selenium-video" .Values.videoRecorder.nameOverride) $ | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand Down Expand Up @@ -547,7 +547,7 @@ template:
volumes:
- name: {{ .Values.nodeConfigMap.scriptVolumeMountName }}
configMap:
name: {{ .Values.nodeConfigMap.name }}
name: {{ tpl .Values.nodeConfigMap.name $ }}
defaultMode: {{ .Values.nodeConfigMap.defaultMode }}
- name: dshm
emptyDir:
Expand Down Expand Up @@ -599,8 +599,8 @@ Get the url of the grid. If the external url can be figured out from the ingress
{{- if .Values.ingress.enabled -}}
{{- if and (not .Values.ingress.hostname) .Values.global.K8S_PUBLIC_IP -}}
{{- $host = .Values.global.K8S_PUBLIC_IP -}}
{{- else if and .Values.ingress.hostname (ne .Values.ingress.hostname "selenium-grid.local") -}}
{{- $host = .Values.ingress.hostname -}}
{{- else if and .Values.ingress.hostname (ne (tpl .Values.ingress.hostname $) "selenium-grid.local") -}}
{{- $host = (tpl .Values.ingress.hostname $) -}}
{{- end -}}
{{- else if .Values.global.K8S_PUBLIC_IP -}}
{{- $host = .Values.global.K8S_PUBLIC_IP -}}
Expand Down
6 changes: 3 additions & 3 deletions charts/selenium-grid/templates/distributor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.busConfigMap.name }}
name: {{ tpl .Values.busConfigMap.name $ }}
- configMapRef:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
- configMapRef:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
- secretRef:
name: {{ include "seleniumGrid.common.secrets" $ | quote }}
{{- with .Values.components.extraEnvFrom }}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/event-bus-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.busConfigMap.name }}
name: {{ tpl .Values.busConfigMap.name $ }}
namespace: {{ .Release.Namespace }}
{{- with .Values.busConfigMap.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/templates/event-bus-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
- configMapRef:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
- secretRef:
name: {{ include "seleniumGrid.common.secrets" $ | quote }}
{{- with .Values.components.extraEnvFrom }}
Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/templates/hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
- configMapRef:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
- secretRef:
name: {{ include "seleniumGrid.common.secrets" $ | quote }}
{{- with .Values.hub.extraEnvFrom }}
Expand Down
8 changes: 4 additions & 4 deletions charts/selenium-grid/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if and (or .Values.tls.enabled .Values.tls.ingress.generateTLS) .Values.ingress.hostname (not .Values.ingress.tls) }}
{{- if and (or .Values.tls.enabled .Values.tls.ingress.generateTLS) (tpl .Values.ingress.hostname $) (not .Values.ingress.tls) }}
tls:
- hosts:
- {{ .Values.ingress.hostname | quote }}
- {{ tpl .Values.ingress.hostname $ | quote }}
secretName: {{ include "seleniumGrid.tls.fullname" . | quote }}
{{- else if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
- {{ tpl . $ | quote }}
{{- end }}
secretName: {{ tpl (.secretName) $ | quote }}
{{- end }}
{{- end }}
rules:
{{- if $.Values.ingress.hostname }}
- host: {{ .Values.ingress.hostname }}
- host: {{ tpl $.Values.ingress.hostname $ }}
http:
{{- else }}
- http:
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/logging-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
namespace: {{ .Release.Namespace }}
{{- with .Values.loggingConfigMap.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.nodeConfigMap.name }}
name: {{ tpl .Values.nodeConfigMap.name $ }}
namespace: {{ .Release.Namespace }}
{{- with .Values.nodeConfigMap.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/templates/router-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
- configMapRef:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
- secretRef:
name: {{ include "seleniumGrid.common.secrets" $ | quote }}
{{- with .Values.components.extraEnvFrom }}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/server-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
namespace: {{ .Release.Namespace }}
{{- with .Values.busConfigMap.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
6 changes: 3 additions & 3 deletions charts/selenium-grid/templates/session-map-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
- configMapRef:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
- secretRef:
name: {{ include "seleniumGrid.common.secrets" $ | quote }}
- configMapRef:
name: {{ .Values.busConfigMap.name }}
name: {{ tpl .Values.busConfigMap.name $ }}
{{- with .Values.components.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/templates/session-queuer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ .Values.loggingConfigMap.name }}
name: {{ tpl .Values.loggingConfigMap.name $ }}
- configMapRef:
name: {{ .Values.serverConfigMap.name }}
name: {{ tpl .Values.serverConfigMap.name $ }}
- secretRef:
name: {{ include "seleniumGrid.common.secrets" $ | quote }}
{{- with .Values.components.extraEnvFrom }}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/tls-cert-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data:
{{- if and .Values.ingress.enabled .Values.tls.ingress.generateTLS (not .Values.tls.enabled) }}
{{- $name := default "SeleniumHQ" .Values.tls.ingress.defaultName -}}
{{- $days := default 365 (.Values.tls.ingress.defaultDays | int) -}}
{{- $cn := ternary .Values.tls.ingress.defaultCN .Values.ingress.hostname (empty .Values.ingress.hostname) -}}
{{- $cn := ternary .Values.tls.ingress.defaultCN (tpl .Values.ingress.hostname $) (empty .Values.ingress.hostname) -}}
{{- $server := genSelfSignedCert $cn ( default nil .Values.tls.ingress.defaultIPList ) ( default nil .Values.tls.ingress.defaultSANList ) $days }}
tls.crt: {{ $server.Cert | b64enc }}
tls.key: {{ $server.Key | b64enc }}
Expand Down

0 comments on commit 3be1d42

Please sign in to comment.