From 3be1d4287c65ede51be4fc7e7fbc922bf0d359ce Mon Sep 17 00:00:00 2001 From: Bas M Date: Tue, 23 Jan 2024 17:00:56 +0100 Subject: [PATCH] feat(chart): templating in name(Override) (#2107) Co-authored-by: Viet Nguyen Duc [skip ci] --- charts/selenium-grid/templates/_helpers.tpl | 34 +++++++++---------- .../templates/distributor-deployment.yaml | 6 ++-- .../templates/event-bus-configmap.yaml | 2 +- .../templates/event-bus-deployment.yaml | 4 +-- .../templates/hub-deployment.yaml | 4 +-- charts/selenium-grid/templates/ingress.yaml | 8 ++--- .../templates/logging-configmap.yaml | 2 +- .../templates/node-configmap.yaml | 2 +- .../templates/router-deployment.yaml | 4 +-- .../templates/server-configmap.yaml | 2 +- .../templates/session-map-deployment.yaml | 6 ++-- .../templates/session-queuer-deployment.yaml | 4 +-- .../templates/tls-cert-secret.yaml | 2 +- 13 files changed, 40 insertions(+), 40 deletions(-) diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index ce7a49b48..c41e6d604 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -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 -}} {{/* @@ -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 -}} {{/* @@ -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" -}} @@ -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 -}} {{/* @@ -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: @@ -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 -}} diff --git a/charts/selenium-grid/templates/distributor-deployment.yaml b/charts/selenium-grid/templates/distributor-deployment.yaml index 52578d6c7..c1848faa4 100644 --- a/charts/selenium-grid/templates/distributor-deployment.yaml +++ b/charts/selenium-grid/templates/distributor-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/event-bus-configmap.yaml b/charts/selenium-grid/templates/event-bus-configmap.yaml index ad2b33756..0515aff22 100644 --- a/charts/selenium-grid/templates/event-bus-configmap.yaml +++ b/charts/selenium-grid/templates/event-bus-configmap.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/event-bus-deployment.yaml b/charts/selenium-grid/templates/event-bus-deployment.yaml index ef29a6908..e783625a9 100644 --- a/charts/selenium-grid/templates/event-bus-deployment.yaml +++ b/charts/selenium-grid/templates/event-bus-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/hub-deployment.yaml b/charts/selenium-grid/templates/hub-deployment.yaml index 00fea3f12..60d10d8ed 100644 --- a/charts/selenium-grid/templates/hub-deployment.yaml +++ b/charts/selenium-grid/templates/hub-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/ingress.yaml b/charts/selenium-grid/templates/ingress.yaml index 2f8195b6e..6f53995da 100644 --- a/charts/selenium-grid/templates/ingress.yaml +++ b/charts/selenium-grid/templates/ingress.yaml @@ -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: diff --git a/charts/selenium-grid/templates/logging-configmap.yaml b/charts/selenium-grid/templates/logging-configmap.yaml index 36acc3bde..a8c8de1f2 100644 --- a/charts/selenium-grid/templates/logging-configmap.yaml +++ b/charts/selenium-grid/templates/logging-configmap.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/node-configmap.yaml b/charts/selenium-grid/templates/node-configmap.yaml index 0bb72acb4..bdd72461a 100644 --- a/charts/selenium-grid/templates/node-configmap.yaml +++ b/charts/selenium-grid/templates/node-configmap.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/router-deployment.yaml b/charts/selenium-grid/templates/router-deployment.yaml index 469dc1652..65a980403 100644 --- a/charts/selenium-grid/templates/router-deployment.yaml +++ b/charts/selenium-grid/templates/router-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/server-configmap.yaml b/charts/selenium-grid/templates/server-configmap.yaml index dc3d80b73..33b573aa5 100644 --- a/charts/selenium-grid/templates/server-configmap.yaml +++ b/charts/selenium-grid/templates/server-configmap.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/session-map-deployment.yaml b/charts/selenium-grid/templates/session-map-deployment.yaml index 27d120540..52c5ca42e 100644 --- a/charts/selenium-grid/templates/session-map-deployment.yaml +++ b/charts/selenium-grid/templates/session-map-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/session-queuer-deployment.yaml b/charts/selenium-grid/templates/session-queuer-deployment.yaml index 546090e43..332db749e 100644 --- a/charts/selenium-grid/templates/session-queuer-deployment.yaml +++ b/charts/selenium-grid/templates/session-queuer-deployment.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/tls-cert-secret.yaml b/charts/selenium-grid/templates/tls-cert-secret.yaml index 000a1e5a7..1ed202e1f 100644 --- a/charts/selenium-grid/templates/tls-cert-secret.yaml +++ b/charts/selenium-grid/templates/tls-cert-secret.yaml @@ -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 }}