2 # Copyright © Original (https://github.com/bitnami/charts) VMware, Inc.
3 # Copyright © 2024 Deutsche Telekom
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 {{/* vim: set filetype=mustache: */}}
21 Return the proper Docker Image Registry Secret Names
22 Original, if common way of image definition:
23 {{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image .Values.metrics.image .Values.volumePermissions.image .Values.tls.image) "context" $) -}}
25 {{- define "common.imagePullSecrets" -}}
26 {{- $images := list }}
27 {{- if .Values.image }}
28 {{- if kindIs "map" .Values.image -}}
29 {{- $images = append $images ".Values.image" -}}
32 {{- if .Values.metrics }}
33 {{- if .Values.metrics.image }}
34 {{- if kindIs "map" .Values.metrics.image -}}
35 {{- $images = append $images ".Values.metrics.image" -}}
39 {{- include "common.images._renderPullSecrets" (dict "images" $images "context" $) -}}
43 Return the proper image name
44 {{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }}
46 {{- define "common.images.image" -}}
47 {{- $registryName := .imageRoot.registry -}}
48 {{- $repositoryName := .imageRoot.repository -}}
49 {{- $separator := ":" -}}
50 {{- $termination := .imageRoot.tag | toString -}}
52 {{- if .global.imageRegistry }}
53 {{- $registryName = .global.imageRegistry -}}
56 {{- if .imageRoot.digest }}
57 {{- $separator = "@" -}}
58 {{- $termination = .imageRoot.digest | toString -}}
60 {{- if $registryName }}
61 {{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
63 {{- printf "%s%s%s" $repositoryName $separator $termination -}}
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 }}
74 {{- $images := .images }}
76 {{- if $context.Values.global }}
77 {{- range $context.Values.global.imagePullSecrets -}}
78 {{- if kindIs "map" . -}}
79 {{- $pullSecrets = append $pullSecrets (include "common.tplvalues._render" (dict "value" .name "context" $context)) -}}
81 {{- $pullSecrets = append $pullSecrets (include "common.tplvalues._render" (dict "value" . "context" $context)) -}}
86 {{- range $image := $images -}}
87 {{- if contains "pullSecret" $image -}}
88 {{- range $pullSecret := $image.pullSecrets -}}
89 {{- if kindIs "map" $pullSecret -}}
90 {{- $pullSecrets = append $pullSecrets $pullSecret.name -}}
92 {{- $pullSecrets = append $pullSecrets $pullSecret -}}
98 {{- if (not (empty $pullSecrets)) }}
100 {{- range $pullSecrets | uniq }}
109 Return the proper image version (ingores image revision/prerelease info & fallbacks to chart appVersion)
110 {{ include "common.images.version" ( dict "imageRoot" .Values.path.to.the.image "chart" .Chart ) }}
112 {{- define "common.images._version" -}}
113 {{- $imageTag := .imageRoot.tag | toString -}}
114 {{/* regexp from https://github.com/Masterminds/semver/blob/23f51de38a0866c5ef0bfc42b3f735c73107b700/version.go#L41-L44 */}}
115 {{- 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 -}}
116 {{- $version := semver $imageTag -}}
117 {{- printf "%d.%d.%d" $version.Major $version.Minor $version.Patch -}}
119 {{- print .chart.AppVersion -}}