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