From c42bd2e57348340c38adf33bdfd1c3cda9c36fee Mon Sep 17 00:00:00 2001 From: Per Erik Johan Carlson Date: Tue, 27 Feb 2024 10:47:32 +0100 Subject: [PATCH] Add support for image registry and digest --- charts/trino/templates/_helpers.tpl | 23 +++++++++++++++++++ .../templates/deployment-coordinator.yaml | 2 +- charts/trino/templates/deployment-worker.yaml | 2 +- charts/trino/values.yaml | 8 ++++--- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/charts/trino/templates/_helpers.tpl b/charts/trino/templates/_helpers.tpl index ade06df1..dbb96abc 100644 --- a/charts/trino/templates/_helpers.tpl +++ b/charts/trino/templates/_helpers.tpl @@ -92,3 +92,26 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Return the proper image name +{{ include "trino.image" . }} + +Code is inspired from bitnami/common + +*/}} +{{- define "trino.image" -}} +{{- $registryName := .Values.image.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- $separator := ":" -}} +{{- $termination := (default .Chart.AppVersion .Values.image.tag) | toString -}} +{{- if .Values.image.digest }} + {{- $separator = "@" -}} + {{- $termination = .Values.image.digest | toString -}} +{{- end -}} +{{- if $registryName }} + {{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}} +{{- else -}} + {{- printf "%s%s%s" $repositoryName $separator $termination -}} +{{- end -}} +{{- end -}} diff --git a/charts/trino/templates/deployment-coordinator.yaml b/charts/trino/templates/deployment-coordinator.yaml index 8bb70d60..12c53b11 100644 --- a/charts/trino/templates/deployment-coordinator.yaml +++ b/charts/trino/templates/deployment-coordinator.yaml @@ -97,7 +97,7 @@ spec: {{- toYaml .Values.imagePullSecrets | nindent 8 }} containers: - name: {{ .Chart.Name }}-coordinator - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: {{ include "trino.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: {{- toYaml .Values.env | nindent 12 }} diff --git a/charts/trino/templates/deployment-worker.yaml b/charts/trino/templates/deployment-worker.yaml index 99a3281f..e23ed60b 100644 --- a/charts/trino/templates/deployment-worker.yaml +++ b/charts/trino/templates/deployment-worker.yaml @@ -75,7 +75,7 @@ spec: {{- toYaml .Values.imagePullSecrets | nindent 8 }} containers: - name: {{ .Chart.Name }}-worker - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: {{ include "trino.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: {{- toYaml .Values.env | nindent 12 }} diff --git a/charts/trino/values.yaml b/charts/trino/values.yaml index e6eccf1e..4c3ca2d6 100644 --- a/charts/trino/values.yaml +++ b/charts/trino/values.yaml @@ -3,11 +3,13 @@ # Declare variables to be passed into your templates. image: - repository: trinodb/trino - pullPolicy: IfNotPresent + registry: "" # Trino image registry + repository: trinodb/trino # Trind image repository # Overrides the image tag whose default is the chart version. # Same value as Chart.yaml#appVersion - tag: 432 + tag: "" # Trino image tag. Default is appVersion from Chart.yaml + digest: "" # Trino image digest as `sha256:abcd...`. Please note this parameter, if set, will override the tag + pullPolicy: IfNotPresent imagePullSecrets: - name: registry-credentials