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") .) }}
70 {{- define "repositoryGenerator.image._helper" -}}
71 {{- $dot := default . .dot -}}
72 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
73 {{- $image := .image }}
74 {{- $repoName := first (pluck $image $initRoot.imageRepoMapping) }}
75 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" $repoName ) .) }}/{{- first (pluck $image $dot.Values.global $initRoot.global) -}}
78 {{- define "repositoryGenerator.image.busybox" -}}
79 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "busyboxImage") .) }}
82 {{- define "repositoryGenerator.image.curl" -}}
83 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "curlImage") .) }}
86 {{- define "repositoryGenerator.image.dcaepolicysync" -}}
87 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "dcaePolicySyncImage") .) }}
90 {{- define "repositoryGenerator.image.envsubst" -}}
91 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "envsubstImage") .) }}
94 {{- define "repositoryGenerator.image.htpasswd" -}}
95 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "htpasswdImage") .) }}
98 {{- define "repositoryGenerator.image.jre" -}}
99 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "jreImage") .) }}
102 {{- define "repositoryGenerator.image.kubectl" -}}
103 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "kubectlImage") .) }}
106 {{- define "repositoryGenerator.image.logging" -}}
107 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "loggingImage") .) }}
110 {{- define "repositoryGenerator.image.mariadb" -}}
111 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "mariadbImage") .) }}
114 {{- define "repositoryGenerator.image.nginx" -}}
115 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "nginxImage") .) }}
118 {{- define "repositoryGenerator.image.postgres" -}}
119 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "postgresImage") .) }}
122 {{- define "repositoryGenerator.image.readiness" -}}
123 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "readinessImage") .) }}
127 Resolve the image repository secret token.
128 The value for .Values.global.repositoryCred is used if provided:
132 mail: email (optional)
133 You can also set the same things for dockerHub, elastic and googleK8s if
136 {{- define "repositoryGenerator.secret" -}}
137 {{- $dot := default . .dot -}}
138 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
139 {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}}
140 {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
141 {{- $repoCreds := "" }}
142 {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
143 {{- $repo := $subchartDot.Values.global.repository }}
144 {{- $cred := $subchartDot.Values.global.repositoryCred }}
145 {{- $mail := default "@" $cred.mail }}
146 {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
147 {{- $repoCreds = printf "\"%s\": {\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $repo $cred.user $cred.password $mail $auth }}
149 {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
150 {{- $dhRepo := $subchartDot.Values.global.dockerHubRepository }}
151 {{- $dhCred := $subchartDot.Values.global.dockerHubRepositoryCred }}
152 {{- $dhMail := default "@" $dhCred.mail }}
153 {{- $dhAuth := printf "%s:%s" $dhCred.user $dhCred.password | b64enc }}
154 {{- $dhRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $dhRepo $dhCred.user $dhCred.password $dhMail $dhAuth }}
155 {{- if eq "" $repoCreds }}
156 {{- $repoCreds = $dhRepoCreds }}
158 {{- $repoCreds = printf "%s, %s" $repoCreds $dhRepoCreds }}
161 {{- if $subchartDot.Values.global.elasticRepositoryCred }}
162 {{- $eRepo := $subchartDot.Values.global.elasticRepository }}
163 {{- $eCred := $subchartDot.Values.global.elasticRepositoryCred }}
164 {{- $eMail := default "@" $eCred.mail }}
165 {{- $eAuth := printf "%s:%s" $eCred.user $eCred.password | b64enc }}
166 {{- $eRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $eRepo $eCred.user $eCred.password $eMail $eAuth }}
167 {{- if eq "" $repoCreds }}
168 {{- $repoCreds = $eRepoCreds }}
170 {{- $repoCreds = printf "%s, %s" $repoCreds $eRepoCreds }}
173 {{- if $subchartDot.Values.global.googleK8sRepositoryCred }}
174 {{- $gcrRepo := $subchartDot.Values.global.googleK8sRepository }}
175 {{- $gcrCred := $subchartDot.Values.global.googleK8sRepositoryCred }}
176 {{- $gcrMail := default "@" $gcrCred.mail }}
177 {{- $gcrAuth := printf "%s:%s" $gcrCred.user $gcrCred.password | b64enc }}
178 {{- $gcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $gcrRepo $gcrCred.user $gcrCred.password $gcrMail $gcrAuth }}
179 {{- if eq "" $repoCreds }}
180 {{- $repoCreds = $gcrRepoCreds }}
182 {{- $repoCreds = printf "%s, %s" $repoCreds $gcrRepoCreds }}
185 {{- printf "{%s}" $repoCreds | b64enc -}}