3 SPDX-License-Identifier: APACHE-2.0
6 {{/* vim: set filetype=mustache: */}}
8 Return the proper image name
9 {{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }}
11 {{- define "common.images.image" -}}
12 {{- $registryName := .imageRoot.registry -}}
13 {{- $repositoryName := .imageRoot.repository -}}
14 {{- $separator := ":" -}}
15 {{- $termination := .imageRoot.tag | toString -}}
17 {{- if .global.imageRegistry }}
18 {{- $registryName = .global.imageRegistry -}}
21 {{- if .imageRoot.digest }}
22 {{- $separator = "@" -}}
23 {{- $termination = .imageRoot.digest | toString -}}
25 {{- if $registryName }}
26 {{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
28 {{- printf "%s%s%s" $repositoryName $separator $termination -}}
33 Return the proper Docker Image Registry Secret Names (deprecated: use common.images.renderPullSecrets instead)
34 {{ include "common.images.pullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "global" .Values.global) }}
36 {{- define "common.images.pullSecrets" -}}
37 {{- $pullSecrets := list }}
40 {{- range .global.imagePullSecrets -}}
41 {{- if kindIs "map" . -}}
42 {{- $pullSecrets = append $pullSecrets .name -}}
44 {{- $pullSecrets = append $pullSecrets . -}}
50 {{- range .pullSecrets -}}
51 {{- if kindIs "map" . -}}
52 {{- $pullSecrets = append $pullSecrets .name -}}
54 {{- $pullSecrets = append $pullSecrets . -}}
59 {{- if (not (empty $pullSecrets)) }}
61 {{- range $pullSecrets | uniq }}
68 Return the proper Docker Image Registry Secret Names evaluating values as templates
69 {{ include "common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }}
71 {{- define "common.images.renderPullSecrets" -}}
72 {{- $pullSecrets := list }}
73 {{- $context := .context }}
75 {{- if $context.Values.global }}
76 {{- range $context.Values.global.imagePullSecrets -}}
77 {{- if kindIs "map" . -}}
78 {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" .name "context" $context)) -}}
80 {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}}
86 {{- range .pullSecrets -}}
87 {{- if kindIs "map" . -}}
88 {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" .name "context" $context)) -}}
90 {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}}
95 {{- if (not (empty $pullSecrets)) }}
97 {{- range $pullSecrets | uniq }}
104 Return the proper image version (ingores image revision/prerelease info & fallbacks to chart appVersion)
105 {{ include "common.images.version" ( dict "imageRoot" .Values.path.to.the.image "chart" .Chart ) }}
107 {{- define "common.images.version" -}}
108 {{- $imageTag := .imageRoot.tag | toString -}}
109 {{/* regexp from https://github.com/Masterminds/semver/blob/23f51de38a0866c5ef0bfc42b3f735c73107b700/version.go#L41-L44 */}}
110 {{- if regexMatch `^([0-9]+)(\.[0-9]+)?(\.[0-9]+)?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?$` $imageTag -}}
111 {{- $version := semver $imageTag -}}
112 {{- printf "%d.%d.%d" $version.Major $version.Minor $version.Patch -}}
114 {{- print .chart.AppVersion -}}