Skip to content

Commit

Permalink
Template the password secret name
Browse files Browse the repository at this point in the history
  • Loading branch information
huw0 authored and nineinchnick committed May 30, 2024
1 parent 2ace482 commit 1fceb0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
16 changes: 16 additions & 0 deletions charts/trino/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
6 changes: 1 addition & 5 deletions charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ spec:
{{- if or .Values.auth.passwordAuth .Values.auth.passwordAuthSecret .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 or .Values.auth.passwordAuth .Values.auth.passwordAuthSecret }}
- key: password.db
Expand Down
6 changes: 1 addition & 5 deletions charts/trino/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 1fceb0a

Please sign in to comment.