2 # Copyright © 2017 Amdocs, Bell Canada
3 # Copyright © 2021 AT&T
4 # Modifications Copyright (C) 2021 Nordix Foundation.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 {{- define "repositoryGenerator._repositoryHelper" -}}
20 {{- $dot := default . .dot -}}
21 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
22 {{- $repoName := .repoName }}
23 {{- $overrideName := printf "%s%s" $repoName "Override" }}
24 {{- if (hasKey $dot.Values $overrideName) -}}
25 {{- printf "%s" (first (pluck $overrideName $dot.Values)) -}}
27 {{- first (pluck $repoName $dot.Values.global $initRoot.global) -}}
32 Resolve the name of the common image repository.
34 - .Values.global.repository : default image repository for all ONAP images
35 - .Values.repositoryOverride : override global repository on a per chart basis
37 {{- define "repositoryGenerator.repository" -}}
38 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "repository") .) }}
42 Resolve the name of the dockerHub image repository.
44 - .Values.global.dockerHubRepository : default image dockerHubRepository for all dockerHub images
45 - .Values.dockerHubRepositoryOverride : override global dockerHub repository on a per chart basis
47 {{- define "repositoryGenerator.dockerHubRepository" -}}
48 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "dockerHubRepository") .) }}
52 Resolve the name of the elasticRepository image repository.
54 - .Values.global.elasticRepository : default image elasticRepository for all images using elastic repository
55 - .Values.elasticRepositoryOverride : override global elasticRepository repository on a per chart basis
57 {{- define "repositoryGenerator.elasticRepository" -}}
58 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "elasticRepository") .) }}
62 Resolve the name of the googleK8sRepository image repository.
64 - .Values.global.googleK8sRepository : default image dockerHubRepository for all dockerHub images
65 - .Values.googleK8sRepositoryOverride : override global dockerHub repository on a per chart basis
67 {{- define "repositoryGenerator.googleK8sRepository" -}}
68 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "googleK8sRepository") .) }}
72 Resolve the name of the GithubContainer registry
73 - .Values.global.githubContainerRegistry : default image githubContainerRegistry for all dockerHub images
74 - .Values.githubContainerRegistryOverride : override global githubContainerRegistry on a per chart basis
76 {{- define "repositoryGenerator.githubContainerRegistry" -}}
77 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "githubContainerRegistry") .) }}
80 {{- define "repositoryGenerator.image._helper" -}}
81 {{- $dot := default . .dot -}}
82 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
83 {{- $image := .image }}
84 {{- $repoName := first (pluck $image $initRoot.imageRepoMapping) }}
85 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" $repoName ) .) }}/{{- first (pluck $image $dot.Values.global $initRoot.global) -}}
88 {{- define "repositoryGenerator.image.busybox" -}}
89 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "busyboxImage") .) }}
92 {{- define "repositoryGenerator.image.curl" -}}
93 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "curlImage") .) }}
96 {{- define "repositoryGenerator.image.dcaepolicysync" -}}
97 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dcaePolicySyncImage") .) }}
100 {{- define "repositoryGenerator.image.envsubst" -}}
101 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "envsubstImage") .) }}
104 {{- define "repositoryGenerator.image.htpasswd" -}}
105 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "htpasswdImage") .) }}
108 {{- define "repositoryGenerator.image.jre" -}}
109 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jreImage") .) }}
112 {{- define "repositoryGenerator.image.kubectl" -}}
113 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "kubectlImage") .) }}
116 {{- define "repositoryGenerator.image.logging" -}}
117 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "loggingImage") .) }}
120 {{- define "repositoryGenerator.image.mariadb" -}}
121 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "mariadbImage") .) }}
124 {{- define "repositoryGenerator.image.nginx" -}}
125 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "nginxImage") .) }}
128 {{- define "repositoryGenerator.image.postgres" -}}
129 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "postgresImage") .) }}
132 {{- define "repositoryGenerator.image.readiness" -}}
133 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "readinessImage") .) }}
136 {{- define "repositoryGenerator.image.dbcClient" -}}
137 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dbcClientImage") .) }}
141 Resolve the image repository secret token.
142 The value for .Values.global.repositoryCred is used if provided:
146 mail: email (optional)
147 You can also set the same things for dockerHub, elastic and googleK8s if
150 {{- define "repositoryGenerator.secret" -}}
151 {{- $dot := default . .dot -}}
152 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
153 {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}}
154 {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
155 {{- $repoCreds := "" }}
156 {{- if $subchartDot.Values.global.repositoryCred }}
157 {{- $repo := $subchartDot.Values.global.repository }}
158 {{- $cred := $subchartDot.Values.global.repositoryCred }}
159 {{- $mail := default "@" $cred.mail }}
160 {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
161 {{- $repoCreds = printf "\"%s\": {\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $repo $cred.user $cred.password $mail $auth }}
163 {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
164 {{- $dhRepo := $subchartDot.Values.global.dockerHubRepository }}
165 {{- $dhCred := $subchartDot.Values.global.dockerHubRepositoryCred }}
166 {{- $dhMail := default "@" $dhCred.mail }}
167 {{- $dhAuth := printf "%s:%s" $dhCred.user $dhCred.password | b64enc }}
168 {{- $dhRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $dhRepo $dhCred.user $dhCred.password $dhMail $dhAuth }}
169 {{- if eq "" $repoCreds }}
170 {{- $repoCreds = $dhRepoCreds }}
172 {{- $repoCreds = printf "%s, %s" $repoCreds $dhRepoCreds }}
175 {{- if $subchartDot.Values.global.elasticRepositoryCred }}
176 {{- $eRepo := $subchartDot.Values.global.elasticRepository }}
177 {{- $eCred := $subchartDot.Values.global.elasticRepositoryCred }}
178 {{- $eMail := default "@" $eCred.mail }}
179 {{- $eAuth := printf "%s:%s" $eCred.user $eCred.password | b64enc }}
180 {{- $eRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $eRepo $eCred.user $eCred.password $eMail $eAuth }}
181 {{- if eq "" $repoCreds }}
182 {{- $repoCreds = $eRepoCreds }}
184 {{- $repoCreds = printf "%s, %s" $repoCreds $eRepoCreds }}
187 {{- if $subchartDot.Values.global.googleK8sRepositoryCred }}
188 {{- $gcrRepo := $subchartDot.Values.global.googleK8sRepository }}
189 {{- $gcrCred := $subchartDot.Values.global.googleK8sRepositoryCred }}
190 {{- $gcrMail := default "@" $gcrCred.mail }}
191 {{- $gcrAuth := printf "%s:%s" $gcrCred.user $gcrCred.password | b64enc }}
192 {{- $gcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $gcrRepo $gcrCred.user $gcrCred.password $gcrMail $gcrAuth }}
193 {{- if eq "" $repoCreds }}
194 {{- $repoCreds = $gcrRepoCreds }}
196 {{- $repoCreds = printf "%s, %s" $repoCreds $gcrRepoCreds }}
199 {{- if $subchartDot.Values.global.githubContainerRegistryCred }}
200 {{- $ghcrRepo := $subchartDot.Values.global.githubContainerRegistry }}
201 {{- $ghcrCred := $subchartDot.Values.global.githubContainerRegistryCred }}
202 {{- $ghcrMail := default "@" $ghcrCred.mail }}
203 {{- $ghcrAuth := printf "%s:%s" $ghcrCred.user $ghcrCred.password | b64enc }}
204 {{- $ghcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $ghcrRepo $ghcrCred.user $ghcrCred.password $ghcrMail $ghcrAuth }}
205 {{- if eq "" $repoCreds }}
206 {{- $repoCreds = $ghcrRepoCreds }}
208 {{- $repoCreds = printf "%s, %s" $repoCreds $ghcrRepoCreds }}
211 {{- printf "{%s}" $repoCreds | b64enc -}}