From 477de96a721a18aa99246f207a5e6e56cf56d9ed Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Wed, 29 Dec 2021 12:33:50 +0100 Subject: [PATCH] feat(common): add support for a, renovate compatible, image selector (#1627) --- charts/library/common/Chart.yaml | 2 +- .../templates/lib/controller/_container.tpl | 2 +- .../common/templates/lib/utils/_images.tpl | 15 +++++++++++++++ charts/library/common/values.yaml | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 796d87a1701..adf19d52250 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 8.9.27 +version: 8.10.0 diff --git a/charts/library/common/templates/lib/controller/_container.tpl b/charts/library/common/templates/lib/controller/_container.tpl index a37f2c9d171..65c7a9d17e4 100644 --- a/charts/library/common/templates/lib/controller/_container.tpl +++ b/charts/library/common/templates/lib/controller/_container.tpl @@ -1,7 +1,7 @@ {{- /* The main container included in the controller */ -}} {{- define "common.controller.mainContainer" -}} - name: {{ include "common.names.fullname" . }} - image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }} + image: {{ include "common.images.selector" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- with .Values.command }} command: diff --git a/charts/library/common/templates/lib/utils/_images.tpl b/charts/library/common/templates/lib/utils/_images.tpl index 4a2698aa41b..a7f656ab253 100644 --- a/charts/library/common/templates/lib/utils/_images.tpl +++ b/charts/library/common/templates/lib/utils/_images.tpl @@ -9,6 +9,21 @@ Return the proper image name {{- printf "%s:%s" $repositoryName $tag -}} {{- end -}} +{{/* +Return the image name using the selector +{{ include "common.images.selector" . }} +*/}} +{{- define "common.images.selector" -}} +{{- $imageDict := get .Values "image" }} +{{- $selected := .Values.imageSelector }} +{{- if hasKey .Values $selected }} +{{- $imageDict = get .Values $selected }} +{{- end }} +{{- $repositoryName := $imageDict.repository -}} +{{- $tag :=$imageDict.tag | toString -}} +{{- printf "%s:%s" $repositoryName $tag -}} +{{- end -}} + {{/* Return the proper Docker Image Registry Secret Names (deprecated: use common.images.renderPullSecrets instead) {{ include "common.images.pullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "global" .Values.global) }} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 15bce448ae6..1ecca289238 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -119,6 +119,10 @@ image: # -- image pull policy pullPolicy: +# -- Image Selector allows for easy picking a different image dict, important for the SCALE GUI +imageSelector: "image" + + # -- Override the command(s) for the default container command: [] # -- Override the args for the default container