Merge "[UUI] Service Mesh Compliance for UUI"
[oom.git] / kubernetes / common / repositoryGenerator / templates / _repository.tpl
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Copyright © 2021 AT&T
4 # Modifications Copyright (C) 2021 Nordix Foundation.
5 #
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
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
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.
17 */}}
18
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)) -}}
26   {{- else -}}
27     {{- first (pluck $repoName $dot.Values.global $initRoot.global) -}}
28   {{- end }}
29 {{- end -}}
30
31 {{/*
32   Resolve the name of the common image repository.
33
34   - .Values.global.repository  : default image repository for all ONAP images
35   - .Values.repositoryOverride : override global repository on a per chart basis
36 */}}
37 {{- define "repositoryGenerator.repository" -}}
38   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "repository") .) }}
39 {{- end -}}
40
41 {{/*
42   Resolve the name of the dockerHub image repository.
43
44   - .Values.global.dockerHubRepository  : default image dockerHubRepository for all dockerHub images
45   - .Values.dockerHubRepositoryOverride : override global dockerHub repository on a per chart basis
46 */}}
47 {{- define "repositoryGenerator.dockerHubRepository" -}}
48   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "dockerHubRepository") .) }}
49 {{- end -}}
50
51 {{/*
52   Resolve the name of the elasticRepository image repository.
53
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
56 */}}
57 {{- define "repositoryGenerator.elasticRepository" -}}
58   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "elasticRepository") .) }}
59 {{- end -}}
60
61 {{/*
62   Resolve the name of the googleK8sRepository image repository.
63
64   - .Values.global.googleK8sRepository  : default image dockerHubRepository for all dockerHub images
65   - .Values.googleK8sRepositoryOverride : override global dockerHub repository on a per chart basis
66 */}}
67 {{- define "repositoryGenerator.googleK8sRepository" -}}
68   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "googleK8sRepository") .) }}
69 {{- end -}}
70
71 {{/*
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
75 */}}
76 {{- define "repositoryGenerator.githubContainerRegistry" -}}
77   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "githubContainerRegistry") .) }}
78 {{- end -}}
79
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) -}}
86 {{- end -}}
87
88 {{- define "repositoryGenerator.image.busybox" -}}
89   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "busyboxImage") .) }}
90 {{- end -}}
91
92 {{- define "repositoryGenerator.image.curl" -}}
93   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "curlImage") .) }}
94 {{- end -}}
95
96 {{- define "repositoryGenerator.image.dcaepolicysync" -}}
97   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dcaePolicySyncImage") .) }}
98 {{- end -}}
99
100 {{- define "repositoryGenerator.image.envsubst" -}}
101   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "envsubstImage") .) }}
102 {{- end -}}
103
104 {{- define "repositoryGenerator.image.htpasswd" -}}
105   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "htpasswdImage") .) }}
106 {{- end -}}
107
108 {{- define "repositoryGenerator.image.jetty" -}}
109   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jettyImage") .) }}
110 {{- end -}}
111
112 {{- define "repositoryGenerator.image.jre" -}}
113   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jreImage") .) }}
114 {{- end -}}
115
116 {{- define "repositoryGenerator.image.kubectl" -}}
117   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "kubectlImage") .) }}
118 {{- end -}}
119
120 {{- define "repositoryGenerator.image.logging" -}}
121   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "loggingImage") .) }}
122 {{- end -}}
123
124 {{- define "repositoryGenerator.image.mariadb" -}}
125   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "mariadbImage") .) }}
126 {{- end -}}
127
128 {{- define "repositoryGenerator.image.nginx" -}}
129   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "nginxImage") .) }}
130 {{- end -}}
131
132 {{- define "repositoryGenerator.image.postgres" -}}
133   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "postgresImage") .) }}
134 {{- end -}}
135
136 {{- define "repositoryGenerator.image.readiness" -}}
137   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "readinessImage") .) }}
138 {{- end -}}
139
140 {{- define "repositoryGenerator.image.dbcClient" -}}
141   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dbcClientImage") .) }}
142 {{- end -}}
143
144 {{- define "repositoryGenerator.image.quitQuit" -}}
145   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "quitQuitImage") .) }}
146 {{- end -}}
147
148 {{/*
149   Resolve the image repository secret token.
150   The value for .Values.global.repositoryCred is used if provided:
151   repositoryCred:
152     user: user
153     password: password
154     mail: email (optional)
155   You can also set the same things for dockerHub, elastic and googleK8s if
156   needed.
157   if not needed, set global.repositoryCred.user to empty value.
158 */}}
159 {{- define "repositoryGenerator.secret" -}}
160   {{- $dot := default . .dot -}}
161   {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
162   {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}}
163   {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
164   {{- $repoCreds := "" }}
165   {{- if $subchartDot.Values.global.repositoryCred }}
166   {{-   $repo := $subchartDot.Values.global.repository }}
167   {{-   $cred := $subchartDot.Values.global.repositoryCred }}
168   {{-   if $cred.user }}
169   {{-     $mail := default "@" $cred.mail }}
170   {{-     $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
171   {{-     $repoCreds = printf "\"%s\": {\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $repo $cred.user $cred.password $mail $auth }}
172   {{-   end }}
173   {{- end }}
174   {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
175   {{-   $dhRepo := $subchartDot.Values.global.dockerHubRepository }}
176   {{-   $dhCred := $subchartDot.Values.global.dockerHubRepositoryCred }}
177   {{-   $dhMail := default "@" $dhCred.mail }}
178   {{-   $dhAuth := printf "%s:%s" $dhCred.user $dhCred.password | b64enc }}
179   {{-   $dhRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $dhRepo $dhCred.user $dhCred.password $dhMail $dhAuth }}
180   {{-   if eq "" $repoCreds }}
181   {{-     $repoCreds = $dhRepoCreds }}
182   {{-   else }}
183   {{-     $repoCreds = printf "%s, %s" $repoCreds $dhRepoCreds }}
184   {{-   end }}
185   {{- end }}
186   {{- if $subchartDot.Values.global.elasticRepositoryCred }}
187   {{-   $eRepo := $subchartDot.Values.global.elasticRepository }}
188   {{-   $eCred := $subchartDot.Values.global.elasticRepositoryCred }}
189   {{-   $eMail := default "@" $eCred.mail }}
190   {{-   $eAuth := printf "%s:%s" $eCred.user $eCred.password | b64enc }}
191   {{-   $eRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $eRepo $eCred.user $eCred.password $eMail $eAuth }}
192   {{-   if eq "" $repoCreds }}
193   {{-     $repoCreds = $eRepoCreds }}
194   {{-   else }}
195   {{-     $repoCreds = printf "%s, %s" $repoCreds $eRepoCreds }}
196   {{-   end }}
197   {{- end }}
198   {{- if $subchartDot.Values.global.googleK8sRepositoryCred }}
199   {{-   $gcrRepo := $subchartDot.Values.global.googleK8sRepository }}
200   {{-   $gcrCred := $subchartDot.Values.global.googleK8sRepositoryCred }}
201   {{-   $gcrMail := default "@" $gcrCred.mail }}
202   {{-   $gcrAuth := printf "%s:%s" $gcrCred.user $gcrCred.password | b64enc }}
203   {{-   $gcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $gcrRepo $gcrCred.user $gcrCred.password $gcrMail $gcrAuth }}
204   {{-   if eq "" $repoCreds }}
205   {{-     $repoCreds = $gcrRepoCreds }}
206   {{-   else }}
207   {{-     $repoCreds = printf "%s, %s" $repoCreds $gcrRepoCreds }}
208   {{-   end }}
209   {{- end }}
210   {{- if $subchartDot.Values.global.githubContainerRegistryCred }}
211   {{-   $ghcrRepo := $subchartDot.Values.global.githubContainerRegistry }}
212   {{-   $ghcrCred := $subchartDot.Values.global.githubContainerRegistryCred }}
213   {{-   $ghcrMail := default "@" $ghcrCred.mail }}
214   {{-   $ghcrAuth := printf "%s:%s" $ghcrCred.user $ghcrCred.password | b64enc }}
215   {{-   $ghcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $ghcrRepo $ghcrCred.user $ghcrCred.password $ghcrMail $ghcrAuth }}
216   {{-   if eq "" $repoCreds }}
217   {{-     $repoCreds = $ghcrRepoCreds }}
218   {{-   else }}
219   {{-     $repoCreds = printf "%s, %s" $repoCreds $ghcrRepoCreds }}
220   {{-   end }}
221   {{- end }}
222   {{- printf "{%s}" $repoCreds | b64enc -}}
223 {{- end -}}