From 249e3298f534008591c55f65da6e5470e15f13b1 Mon Sep 17 00:00:00 2001 From: Huw Ayling-Miller Date: Sat, 18 Nov 2023 23:13:59 +0000 Subject: [PATCH 1/2] Template the password secret name --- charts/trino/templates/_helpers.tpl | 16 ++++++++++++++++ .../trino/templates/deployment-coordinator.yaml | 6 +----- charts/trino/templates/secret.yaml | 6 +----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/charts/trino/templates/_helpers.tpl b/charts/trino/templates/_helpers.tpl index a5ddc1b4..891d48ac 100644 --- a/charts/trino/templates/_helpers.tpl +++ b/charts/trino/templates/_helpers.tpl @@ -120,3 +120,19 @@ Code is inspired from bitnami/common {{- end -}} {{- end -}} {{- end -}} + +{{/* +Create the name of the file auth secret to use +*/}} +{{- define "trino.fileAuthSecretName" -}} +{{- if and .Values.auth .Values.auth.passwordAuthSecret }} +{{- .Values.auth.passwordAuthSecret | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }}-file-authentication +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}-file-authentication +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/trino/templates/deployment-coordinator.yaml b/charts/trino/templates/deployment-coordinator.yaml index 1574a399..ed50d086 100644 --- a/charts/trino/templates/deployment-coordinator.yaml +++ b/charts/trino/templates/deployment-coordinator.yaml @@ -67,11 +67,7 @@ spec: {{- if or .Values.auth.passwordAuth .Values.auth.groups }} - name: file-authentication-volume secret: - {{- if and .Values.auth .Values.auth.passwordAuthSecret }} - secretName: {{ .Values.auth.passwordAuthSecret }} - {{- else }} - secretName: trino-file-authentication - {{- end }} + secretName: {{ template "trino.fileAuthSecretName" . }} items: {{- if .Values.auth.passwordAuth }} - key: password.db diff --git a/charts/trino/templates/secret.yaml b/charts/trino/templates/secret.yaml index 445eabc0..dd48f90a 100644 --- a/charts/trino/templates/secret.yaml +++ b/charts/trino/templates/secret.yaml @@ -2,11 +2,7 @@ apiVersion: v1 kind: Secret metadata: - {{- if and .Values.auth .Values.auth.passwordAuthSecret }} - name: {{ .Values.auth.passwordAuthSecret }} - {{- else }} - name: trino-file-authentication - {{- end }} + name: {{ template "trino.fileAuthSecretName" . }} namespace: {{ .Release.Namespace }} labels: {{- include "trino.labels" . | nindent 4 }} From 51c03b4315987f7a7bcbee72c5f2efb61d5ecbce Mon Sep 17 00:00:00 2001 From: Huw Ayling-Miller Date: Sun, 26 May 2024 22:00:53 +0100 Subject: [PATCH 2/2] Fix helper naming and truncation --- charts/trino/templates/_helpers.tpl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/charts/trino/templates/_helpers.tpl b/charts/trino/templates/_helpers.tpl index 891d48ac..9765d0a8 100644 --- a/charts/trino/templates/_helpers.tpl +++ b/charts/trino/templates/_helpers.tpl @@ -16,8 +16,8 @@ If release name contains chart name it will be used as a full name. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} {{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- if hasPrefix .Release.Name $name }} +{{- $name | trunc 63 | trimSuffix "-" }} {{- else }} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} {{- end }} @@ -36,10 +36,10 @@ Create chart name and version as used by the chart label. {{- .Values.coordinatorNameOverride | trunc 63 | trimSuffix "-" }} {{- else }} {{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }}-coordinator +{{- if hasPrefix .Release.Name $name }} +{{- printf "%s-%s" $name "coordinator" | trunc 63 | trimSuffix "-" }} {{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}-coordinator +{{- printf "%s-%s-%s" .Release.Name $name "coordinator" | trunc 63 | trimSuffix "-" }} {{- end }} {{- end }} {{- end }} @@ -49,10 +49,10 @@ Create chart name and version as used by the chart label. {{- .Values.workerNameOverride | trunc 63 | trimSuffix "-" }} {{- else }} {{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }}-worker +{{- if hasPrefix .Release.Name $name }} +{{- printf "%s-%s" $name "worker" | trunc 63 | trimSuffix "-" }} {{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}-worker +{{- printf "%s-%s-%s" .Release.Name $name "worker" | trunc 63 | trimSuffix "-" }} {{- end }} {{- end }} {{- end }} @@ -129,10 +129,10 @@ Create the name of the file auth secret to use {{- .Values.auth.passwordAuthSecret | trunc 63 | trimSuffix "-" }} {{- else }} {{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }}-file-authentication +{{- if hasPrefix .Release.Name $name }} +{{- printf "%s-%s" $name "file-authentication" | trunc 63 | trimSuffix "-" }} {{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}-file-authentication +{{- printf "%s-%s-%s" .Release.Name $name "file-authentication" | trunc 63 | trimSuffix "-" }} {{- end }} {{- end }} {{- end }}