2 # Copyright © 2017 Amdocs, Bell Canada
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 {{- define "repositoryGenerator._repositoryHelper" -}}
18 {{- $dot := default . .dot -}}
19 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
20 {{- $repoName := .repoName }}
21 {{- $overrideName := printf "%s%s" $repoName "Override" }}
22 {{- if (hasKey $dot.Values $overrideName) -}}
23 {{- printf "%s" (first (pluck $overrideName $dot.Values)) -}}
25 {{- first (pluck $repoName $dot.Values.global $initRoot.global) -}}
30 Resolve the name of the common image repository.
32 - .Values.global.repository : default image repository for all ONAP images
33 - .Values.repositoryOverride : override global repository on a per chart basis
35 {{- define "repositoryGenerator.repository" -}}
36 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "repository") .) }}
40 Resolve the name of the dockerHub image repository.
42 - .Values.global.dockerHubRepository : default image dockerHubRepository for all dockerHub images
43 - .Values.dockerHubRepositoryOverride : override global dockerHub repository on a per chart basis
45 {{- define "repositoryGenerator.dockerHubRepository" -}}
46 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "dockerHubRepository") .) }}
50 Resolve the name of the elasticRepository image repository.
52 - .Values.global.elasticRepository : default image elasticRepository for all images using elastic repository
53 - .Values.elasticRepositoryOverride : override global elasticRepository repository on a per chart basis
55 {{- define "repositoryGenerator.elasticRepository" -}}
56 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "elasticRepository") .) }}
60 Resolve the name of the googleK8sRepository image repository.
62 - .Values.global.googleK8sRepository : default image dockerHubRepository for all dockerHub images
63 - .Values.googleK8sRepositoryOverride : override global dockerHub repository on a per chart basis
65 {{- define "repositoryGenerator.googleK8sRepository" -}}
66 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" "googleK8sRepository") .) }}
69 {{- define "repositoryGenerator.image._helper" -}}
70 {{- $dot := default . .dot -}}
71 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
72 {{- $image := .image }}
73 {{- $repoName := first (pluck $image $initRoot.imageRepoMapping) }}
74 {{- include "repositoryGenerator._repositoryHelper" (merge (dict "repoName" $repoName ) .) }}/{{- first (pluck $image $dot.Values.global $initRoot.global) -}}
77 {{- define "repositoryGenerator.image.busybox" -}}
78 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "busyboxImage") .) }}
81 {{- define "repositoryGenerator.image.curl" -}}
82 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "curlImage") .) }}
85 {{- define "repositoryGenerator.image.envsubst" -}}
86 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "envsubstImage") .) }}
89 {{- define "repositoryGenerator.image.htpasswd" -}}
90 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "htpasswdImage") .) }}
93 {{- define "repositoryGenerator.image.kubectl" -}}
94 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "kubectlImage") .) }}
97 {{- define "repositoryGenerator.image.logging" -}}
98 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "loggingImage") .) }}
101 {{- define "repositoryGenerator.image.mariadb" -}}
102 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "mariadbImage") .) }}
105 {{- define "repositoryGenerator.image.nginx" -}}
106 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "nginxImage") .) }}
109 {{- define "repositoryGenerator.image.postgres" -}}
110 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "postgresImage") .) }}
113 {{- define "repositoryGenerator.image.readiness" -}}
114 {{- include "repositoryGenerator.image._helper" (merge (dict "image" "readinessImage") .) }}
118 Resolve the image repository secret token.
119 The value for .Values.global.repositoryCred is used if provided:
123 mail: email (optional)
124 You can also set the same things for dockerHub, elastic and googleK8s if
127 {{- define "repositoryGenerator.secret" -}}
128 {{- $dot := default . .dot -}}
129 {{- $initRoot := default $dot.Values.repositoryGenerator .initRoot -}}
130 {{/* Our version of helm doesn't support deepCopy so we need this nasty trick */}}
131 {{- $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
132 {{- $repoCreds := "" }}
133 {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
134 {{- $repo := $subchartDot.Values.global.repository }}
135 {{- $cred := $subchartDot.Values.global.repositoryCred }}
136 {{- $mail := default "@" $cred.mail }}
137 {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
138 {{- $repoCreds = printf "\"%s\": {\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $repo $cred.user $cred.password $mail $auth }}
140 {{- if $subchartDot.Values.global.dockerHubRepositoryCred }}
141 {{- $dhRepo := $subchartDot.Values.global.dockerHubRepository }}
142 {{- $dhCred := $subchartDot.Values.global.dockerHubRepositoryCred }}
143 {{- $dhMail := default "@" $dhCred.mail }}
144 {{- $dhAuth := printf "%s:%s" $dhCred.user $dhCred.password | b64enc }}
145 {{- $dhRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $dhRepo $dhCred.user $dhCred.password $dhMail $dhAuth }}
146 {{- if eq "" $repoCreds }}
147 {{- $repoCreds = $dhRepoCreds }}
149 {{- $repoCreds = printf "%s, %s" $repoCreds $dhRepoCreds }}
152 {{- if $subchartDot.Values.global.elasticRepositoryCred }}
153 {{- $eRepo := $subchartDot.Values.global.elasticRepository }}
154 {{- $eCred := $subchartDot.Values.global.elasticRepositoryCred }}
155 {{- $eMail := default "@" $eCred.mail }}
156 {{- $eAuth := printf "%s:%s" $eCred.user $eCred.password | b64enc }}
157 {{- $eRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $eRepo $eCred.user $eCred.password $eMail $eAuth }}
158 {{- if eq "" $repoCreds }}
159 {{- $repoCreds = $eRepoCreds }}
161 {{- $repoCreds = printf "%s, %s" $repoCreds $eRepoCreds }}
164 {{- if $subchartDot.Values.global.googleK8sRepositoryCred }}
165 {{- $gcrRepo := $subchartDot.Values.global.googleK8sRepository }}
166 {{- $gcrCred := $subchartDot.Values.global.googleK8sRepositoryCred }}
167 {{- $gcrMail := default "@" $gcrCred.mail }}
168 {{- $gcrAuth := printf "%s:%s" $gcrCred.user $gcrCred.password | b64enc }}
169 {{- $gcrRepoCreds := printf "\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}" $gcrRepo $gcrCred.user $gcrCred.password $gcrMail $gcrAuth }}
170 {{- if eq "" $repoCreds }}
171 {{- $repoCreds = $gcrRepoCreds }}
173 {{- $repoCreds = printf "%s, %s" $repoCreds $gcrRepoCreds }}
176 {{- printf "{%s}" $repoCreds | b64enc -}}