Merge "[AAI] Add model-loader tracing config"
[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 quay.io Repository image repository.
63
64   - .Values.global.quayRepository  : default image quayRepository for all images using quay repository
65   - .Values.quayRepositoryOverride : override global quayRepository repository on a per chart basis
66 */}}
67 {{- define "repositoryGenerator.quayRepository" -}}
68   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "quayRepository") .) }}
69 {{- end -}}
70
71 {{/*
72   Resolve the name of the googleK8sRepository image repository.
73
74   - .Values.global.googleK8sRepository  : default image dockerHubRepository for all dockerHub images
75   - .Values.googleK8sRepositoryOverride : override global dockerHub repository on a per chart basis
76 */}}
77 {{- define "repositoryGenerator.googleK8sRepository" -}}
78   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "googleK8sRepository") .) }}
79 {{- end -}}
80
81 {{/*
82   Resolve the name of the GithubContainer registry
83   - .Values.global.githubContainerRegistry  : default image githubContainerRegistry for all dockerHub images
84   - .Values.githubContainerRegistryOverride : override global githubContainerRegistry on a per chart basis
85 */}}
86 {{- define "repositoryGenerator.githubContainerRegistry" -}}
87   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "githubContainerRegistry") .) }}
88 {{- end -}}
89
90 {{- define "repositoryGenerator.image._helper" -}}
91   {{- $dot := default . .dot -}}
92   {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
93   {{- $image := .image }}
94   {{- $repoName := first (pluck $image $initRoot.imageRepoMapping) }}
95   {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" $repoName ) .) }}/{{- first (pluck $image $dot.Values.global $initRoot.global) -}}
96 {{- end -}}
97
98 {{- define "repositoryGenerator.image.busybox" -}}
99   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "busyboxImage") .) }}
100 {{- end -}}
101
102 {{- define "repositoryGenerator.image.curl" -}}
103   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "curlImage") .) }}
104 {{- end -}}
105
106 {{- define "repositoryGenerator.image.dcaepolicysync" -}}
107   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dcaePolicySyncImage") .) }}
108 {{- end -}}
109
110 {{- define "repositoryGenerator.image.envsubst" -}}
111   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "envsubstImage") .) }}
112 {{- end -}}
113
114 {{- define "repositoryGenerator.image.htpasswd" -}}
115   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "htpasswdImage") .) }}
116 {{- end -}}
117
118 {{- define "repositoryGenerator.image.jetty" -}}
119   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jettyImage") .) }}
120 {{- end -}}
121
122 {{- define "repositoryGenerator.image.jre" -}}
123   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jreImage") .) }}
124 {{- end -}}
125
126 {{- define "repositoryGenerator.image.kubectl" -}}
127   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "kubectlImage") .) }}
128 {{- end -}}
129
130 {{- define "repositoryGenerator.image.logging" -}}
131   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "loggingImage") .) }}
132 {{- end -}}
133
134 {{- define "repositoryGenerator.image.mariadb" -}}
135   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "mariadbImage") .) }}
136 {{- end -}}
137
138 {{- define "repositoryGenerator.image.nginx" -}}
139   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "nginxImage") .) }}
140 {{- end -}}
141
142 {{- define "repositoryGenerator.image.postgres" -}}
143   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "postgresImage") .) }}
144 {{- end -}}
145
146 {{- define "repositoryGenerator.image.readiness" -}}
147   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "readinessImage") .) }}
148 {{- end -}}
149
150 {{- define "repositoryGenerator.image.drProvClient" -}}
151   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "drProvClientImage") .) }}
152 {{- end -}}
153
154 {{- define "repositoryGenerator.image.quitQuit" -}}
155   {{- include "repositoryGenerator.image._helper" (merge (dict "image" "quitQuitImage") .) }}
156 {{- end -}}
157
158 {{/*
159   Resolve the image repository secret token.
160   The value for .Values.global.repositoryCred is used if provided:
161   repositoryCred:
162     user: user
163     password: password
164     mail: email (optional)
165   You can also set the same things for dockerHub, elastic and googleK8s if
166   needed.
167   if not needed, set global.repositoryCred.user to empty value.
168 */}}
169 {{- define "repositoryGenerator.secret" -}}
170   {{- $dot := default . .dot -}}
171   {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
172   {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}}
173   {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
174   {{- $repoCreds := "" }}
175   {{- if $subchartDot.Values.global.repositoryCred }}
176   {{-   $repo := $subchartDot.Values.global.repository }}
177   {{-   $cred := $subchartDot.Values.global.repositoryCred }}
178   {{-   if $cred.user }}
179   {{-     $mail := default "@" $cred.mail }}
180   {{-     $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
181   {{-     $repoCreds = printf "\"%s\": {\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $repo $cred.user $cred.password $mail $auth }}
182   {{-   end }}
183   {{- end }}
184   {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
185   {{-   $dhRepo := $subchartDot.Values.global.dockerHubRepository }}
186   {{-   $dhCred := $subchartDot.Values.global.dockerHubRepositoryCred }}
187   {{-   $dhMail := default "@" $dhCred.mail }}
188   {{-   $dhAuth := printf "%s:%s" $dhCred.user $dhCred.password | b64enc }}
189   {{-   $dhRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $dhRepo $dhCred.user $dhCred.password $dhMail $dhAuth }}
190   {{-   if eq "" $repoCreds }}
191   {{-     $repoCreds = $dhRepoCreds }}
192   {{-   else }}
193   {{-     $repoCreds = printf "%s, %s" $repoCreds $dhRepoCreds }}
194   {{-   end }}
195   {{- end }}
196   {{- if $subchartDot.Values.global.elasticRepositoryCred }}
197   {{-   $eRepo := $subchartDot.Values.global.elasticRepository }}
198   {{-   $eCred := $subchartDot.Values.global.elasticRepositoryCred }}
199   {{-   $eMail := default "@" $eCred.mail }}
200   {{-   $eAuth := printf "%s:%s" $eCred.user $eCred.password | b64enc }}
201   {{-   $eRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $eRepo $eCred.user $eCred.password $eMail $eAuth }}
202   {{-   if eq "" $repoCreds }}
203   {{-     $repoCreds = $eRepoCreds }}
204   {{-   else }}
205   {{-     $repoCreds = printf "%s, %s" $repoCreds $eRepoCreds }}
206   {{-   end }}
207   {{- end }}
208   {{- if $subchartDot.Values.global.googleK8sRepositoryCred }}
209   {{-   $gcrRepo := $subchartDot.Values.global.googleK8sRepository }}
210   {{-   $gcrCred := $subchartDot.Values.global.googleK8sRepositoryCred }}
211   {{-   $gcrMail := default "@" $gcrCred.mail }}
212   {{-   $gcrAuth := printf "%s:%s" $gcrCred.user $gcrCred.password | b64enc }}
213   {{-   $gcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $gcrRepo $gcrCred.user $gcrCred.password $gcrMail $gcrAuth }}
214   {{-   if eq "" $repoCreds }}
215   {{-     $repoCreds = $gcrRepoCreds }}
216   {{-   else }}
217   {{-     $repoCreds = printf "%s, %s" $repoCreds $gcrRepoCreds }}
218   {{-   end }}
219   {{- end }}
220   {{- if $subchartDot.Values.global.githubContainerRegistryCred }}
221   {{-   $ghcrRepo := $subchartDot.Values.global.githubContainerRegistry }}
222   {{-   $ghcrCred := $subchartDot.Values.global.githubContainerRegistryCred }}
223   {{-   $ghcrMail := default "@" $ghcrCred.mail }}
224   {{-   $ghcrAuth := printf "%s:%s" $ghcrCred.user $ghcrCred.password | b64enc }}
225   {{-   $ghcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $ghcrRepo $ghcrCred.user $ghcrCred.password $ghcrMail $ghcrAuth }}
226   {{-   if eq "" $repoCreds }}
227   {{-     $repoCreds = $ghcrRepoCreds }}
228   {{-   else }}
229   {{-     $repoCreds = printf "%s, %s" $repoCreds $ghcrRepoCreds }}
230   {{-   end }}
231   {{- end }}
232   {{- printf "{%s}" $repoCreds | b64enc -}}
233 {{- end -}}