Fixes for ric-aux
[it/dep.git] / ric-platform / 50-RIC-Platform / helm / common / templates / _repository.tpl
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #   Copyright (c) 2019 Nokia.                                                  #
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 {{/*
19   Resolve the name of the common image repository.
20   The value for .Values.repository is used by default,
21   unless either override mechanism is used.
22
23   - .Values.global.repository  : override default image repository for all images
24   - .Values.repositoryOverride : override global and default image repository on a per image basis
25 */}}
26 {{- define "common.repository" -}}
27   {{- $componentname := .Chart.Name -}}
28   {{- $firsttier := (index .Values (printf "%s" $componentname)) -}}
29   {{- if $firsttier -}}
30     {{- $secondtier := (index .Values (printf "%s" $componentname) (printf "%s" "repositoryOverride")) -}}
31     {{- if $secondtier -}}
32       {{- printf "%s" $secondtier -}}
33     {{- else -}}
34       {{- if .Values.global -}}
35         {{- if .Values.global.repository -}}
36           {{- printf "%s" .Values.global.repository -}}
37         {{- else -}}
38           {{- printf "%s" .Values.repository -}}
39         {{- end -}}
40       {{- else -}}
41         {{- printf "%s" .Values.repository -}}
42       {{- end -}}  
43     {{- end -}}
44   {{- else -}}
45     {{- if .Values.global -}}
46       {{- if .Values.global.repository -}}
47         {{- printf "%s" .Values.global.repository -}}
48       {{- else -}}
49         {{- printf "%s" .Values.repository -}}
50       {{- end -}}
51     {{- else -}}
52       {{- printf "%s" .Values.repository -}}
53     {{- end -}}  
54   {{- end -}}
55 {{- end -}}
56
57
58 {{/*
59   Resolve the docker image repository secret token configmap.
60   The secret token should be installed by K8S system admin.
61   The value for .Values.repositoryCred is used by default,
62   unless either override mechanism is used.
63
64   - .Values.global.repositoryCred  : override default docker registry credential
65   - .Values.repositoryCredOverride : override global and default docker registry credential
66 */}}
67 {{- define "common.repositoryCred" -}}
68   {{- if .Values.repositoryCredOverride -}}
69     {{- printf "%s" .Values.repositoryCredOverride -}}
70   {{- else -}}
71     {{- if  .Values.global -}}
72       {{- if .Values.global.repositoryCred -}}
73         {{- printf "%s" .Values.global.repositoryCred -}}
74       {{- else -}}
75         {{- printf "%s" .Values.repositoryCred -}}
76       {{- end -}}
77     {{- else -}}
78       {{- printf "%s" .Values.repositoryCred -}}
79     {{- end -}}
80   {{- end -}}
81 {{- end -}}
82
83
84 {{/*
85   Define the golbal image pull policy.
86   The value for .Values.imagePullPolicy is used by default,
87   unless either override mechanism is used.
88
89   - .Values.global.imagePullPolicy  : override default pull policy
90   - .Values.imagePullPolicyOverride : override global and default pull policy
91 */}}
92 {{- define "common.pullPolicy" -}}
93   {{- if .Values.imagePullPolicyOverride -}}
94     {{- printf "%s" .Values.imagePullPolicyOverride -}}
95   {{- else -}}
96     {{- if  .Values.global -}}
97       {{- if .Values.global.imagePullPolicy -}}
98         {{- printf "%s" .Values.global.imagePullPolicy -}}
99       {{- else -}}
100         {{- printf "%s" .Values.imagePullPolicy -}}
101       {{- end -}}
102     {{- else -}}
103       {{- printf "%s" .Values.imagePullPolicy -}}
104     {{- end -}}
105   {{- end -}}
106 {{- end -}}
107
108
109 {{/*
110   Resolve the docker registry certificate name.
111   The value for .Values.repositoryCert is used by default,
112   unless either override mechanism is used.
113
114   - .Values.global.repositoryCert  : override default repository certificate
115   - .Values.repositoryCertOverride : override global and default repository certificate
116 */}}
117 {{- define "common.repositorycert" -}}
118   {{- if .Values.repositoryCertOverride -}}
119     {{- printf "%s" .Values.repositoryCertOverride -}}
120   {{- else -}}
121     {{- if  .Values.global -}}
122       {{- if .Values.global.repositoryCert -}}
123         {{- printf "%s" .Values.global.repositoryCert -}}
124       {{- else -}}
125         {{- printf "%s" .Values.repositoryCert -}}
126       {{- end -}}
127     {{- else -}}
128       {{- printf "%s" .Values.repositoryCert -}}
129     {{- end -}}
130   {{- end -}}
131 {{- end -}}
132
133
134
135
136
137
138 {{/*
139 Generate certificates for the docker registry
140 */}}
141 {{- define "common.repository.gen-certs" -}}
142 {{- $altNames := list ( printf "docker.%s" .Values.ingress.hostpostfix ) -}}
143 {{- $ca := genCA "docker-registry-ca" 365 -}}
144 {{- $cert := genSignedCert ( include "nexus.name" . ) nil $altNames 365 $ca -}}
145 tls.crt: {{ $cert.Cert | b64enc }}
146 tls.key: {{ $cert.Key | b64enc }}
147 {{- end -}}