2 # Copyright © 2017 Amdocs, Bell Canada
3 # Copyright © 2021 AT&T
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 {{- define "repositoryGenerator._repositoryHelper" -}}
19 {{- $dot := default . .dot -}}
20 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
21 {{- $repoName := .repoName }}
22 {{- $overrideName := printf "%s%s" $repoName "Override" }}
23 {{- if (hasKey $dot.Values $overrideName) -}}
24 {{- printf "%s" (first (pluck $overrideName $dot.Values)) -}}
26 {{- first (pluck $repoName $dot.Values.global $initRoot.global) -}}
31 Resolve the name of the common image repository.
33 - .Values.global.repository : default image repository for all ONAP images
34 - .Values.repositoryOverride : override global repository on a per chart basis
36 {{- define "repositoryGenerator.repository" -}}
37 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "repository") .) }}
41 Resolve the name of the dockerHub image repository.
43 - .Values.global.dockerHubRepository : default image dockerHubRepository for all dockerHub images
44 - .Values.dockerHubRepositoryOverride : override global dockerHub repository on a per chart basis
46 {{- define "repositoryGenerator.dockerHubRepository" -}}
47 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "dockerHubRepository") .) }}
51 Resolve the name of the elasticRepository image repository.
53 - .Values.global.elasticRepository : default image elasticRepository for all images using elastic repository
54 - .Values.elasticRepositoryOverride : override global elasticRepository repository on a per chart basis
56 {{- define "repositoryGenerator.elasticRepository" -}}
57 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "elasticRepository") .) }}
61 Resolve the name of the googleK8sRepository image repository.
63 - .Values.global.googleK8sRepository : default image dockerHubRepository for all dockerHub images
64 - .Values.googleK8sRepositoryOverride : override global dockerHub repository on a per chart basis
66 {{- define "repositoryGenerator.googleK8sRepository" -}}
67 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "googleK8sRepository") .) }}
71 Resolve the name of the GithubContainer registry
72 - .Values.global.githubContainerRegistry : default image githubContainerRegistry for all dockerHub images
73 - .Values.githubContainerRegistryOverride : override global githubContainerRegistry on a per chart basis
75 {{- define "repositoryGenerator.githubContainerRegistry" -}}
76 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "githubContainerRegistry") .) }}
79 {{- define "repositoryGenerator.image._helper" -}}
80 {{- $dot := default . .dot -}}
81 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
82 {{- $image := .image }}
83 {{- $repoName := first (pluck $image $initRoot.imageRepoMapping) }}
84 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" $repoName ) .) }}/{{- first (pluck $image $dot.Values.global $initRoot.global) -}}
87 {{- define "repositoryGenerator.image.busybox" -}}
88 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "busyboxImage") .) }}
91 {{- define "repositoryGenerator.image.curl" -}}
92 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "curlImage") .) }}
95 {{- define "repositoryGenerator.image.dcaepolicysync" -}}
96 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dcaePolicySyncImage") .) }}
99 {{- define "repositoryGenerator.image.envsubst" -}}
100 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "envsubstImage") .) }}
103 {{- define "repositoryGenerator.image.htpasswd" -}}
104 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "htpasswdImage") .) }}
107 {{- define "repositoryGenerator.image.jre" -}}
108 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jreImage") .) }}
111 {{- define "repositoryGenerator.image.kubectl" -}}
112 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "kubectlImage") .) }}
115 {{- define "repositoryGenerator.image.logging" -}}
116 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "loggingImage") .) }}
119 {{- define "repositoryGenerator.image.mariadb" -}}
120 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "mariadbImage") .) }}
123 {{- define "repositoryGenerator.image.nginx" -}}
124 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "nginxImage") .) }}
127 {{- define "repositoryGenerator.image.postgres" -}}
128 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "postgresImage") .) }}
131 {{- define "repositoryGenerator.image.readiness" -}}
132 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "readinessImage") .) }}
136 Resolve the image repository secret token.
137 The value for .Values.global.repositoryCred is used if provided:
141 mail: email (optional)
142 You can also set the same things for dockerHub, elastic and googleK8s if
145 {{- define "repositoryGenerator.secret" -}}
146 {{- $dot := default . .dot -}}
147 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
148 {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}}
149 {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
150 {{- $repoCreds := "" }}
151 {{- if $subchartDot.Values.global.repositoryCred }}
152 {{- $repo := $subchartDot.Values.global.repository }}
153 {{- $cred := $subchartDot.Values.global.repositoryCred }}
154 {{- $mail := default "@" $cred.mail }}
155 {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
156 {{- $repoCreds = printf "\"%s\": {\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $repo $cred.user $cred.password $mail $auth }}
158 {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
159 {{- $dhRepo := $subchartDot.Values.global.dockerHubRepository }}
160 {{- $dhCred := $subchartDot.Values.global.dockerHubRepositoryCred }}
161 {{- $dhMail := default "@" $dhCred.mail }}
162 {{- $dhAuth := printf "%s:%s" $dhCred.user $dhCred.password | b64enc }}
163 {{- $dhRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $dhRepo $dhCred.user $dhCred.password $dhMail $dhAuth }}
164 {{- if eq "" $repoCreds }}
165 {{- $repoCreds = $dhRepoCreds }}
167 {{- $repoCreds = printf "%s, %s" $repoCreds $dhRepoCreds }}
170 {{- if $subchartDot.Values.global.elasticRepositoryCred }}
171 {{- $eRepo := $subchartDot.Values.global.elasticRepository }}
172 {{- $eCred := $subchartDot.Values.global.elasticRepositoryCred }}
173 {{- $eMail := default "@" $eCred.mail }}
174 {{- $eAuth := printf "%s:%s" $eCred.user $eCred.password | b64enc }}
175 {{- $eRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $eRepo $eCred.user $eCred.password $eMail $eAuth }}
176 {{- if eq "" $repoCreds }}
177 {{- $repoCreds = $eRepoCreds }}
179 {{- $repoCreds = printf "%s, %s" $repoCreds $eRepoCreds }}
182 {{- if $subchartDot.Values.global.googleK8sRepositoryCred }}
183 {{- $gcrRepo := $subchartDot.Values.global.googleK8sRepository }}
184 {{- $gcrCred := $subchartDot.Values.global.googleK8sRepositoryCred }}
185 {{- $gcrMail := default "@" $gcrCred.mail }}
186 {{- $gcrAuth := printf "%s:%s" $gcrCred.user $gcrCred.password | b64enc }}
187 {{- $gcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $gcrRepo $gcrCred.user $gcrCred.password $gcrMail $gcrAuth }}
188 {{- if eq "" $repoCreds }}
189 {{- $repoCreds = $gcrRepoCreds }}
191 {{- $repoCreds = printf "%s, %s" $repoCreds $gcrRepoCreds }}
194 {{- if $subchartDot.Values.global.githubContainerRegistryCred }}
195 {{- $ghcrRepo := $subchartDot.Values.global.githubContainerRegistry }}
196 {{- $ghcrCred := $subchartDot.Values.global.githubContainerRegistryCred }}
197 {{- $ghcrMail := default "@" $ghcrCred.mail }}
198 {{- $ghcrAuth := printf "%s:%s" $ghcrCred.user $ghcrCred.password | b64enc }}
199 {{- $ghcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $ghcrRepo $ghcrCred.user $ghcrCred.password $ghcrMail $ghcrAuth }}
200 {{- if eq "" $repoCreds }}
201 {{- $repoCreds = $ghcrRepoCreds }}
203 {{- $repoCreds = printf "%s, %s" $repoCreds $ghcrRepoCreds }}
206 {{- printf "{%s}" $repoCreds | b64enc -}}