This patch introduces a new structure of the it/dep repo.
[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   {{- if .Values.repositoryOverride -}}
28     {{- printf "%s" .Values.repositoryOverride -}}
29   {{- else -}}
30     {{- if .Values.global -}}
31       {{- if .Values.global.repository -}}
32         {{- printf "%s" .Values.global.repository -}}
33       {{- else -}}
34         {{- printf "%s" .Values.repository -}}
35       {{- end -}}
36     {{- else -}}
37       {{- printf "%s" .Values.repository -}}
38     {{- end -}}  
39   {{- end -}}
40 {{- end -}}
41
42
43 {{/*
44   Resolve the docker image repository secret token configmap.
45   The secret token should be installed by K8S system admin.
46   The value for .Values.repositoryCred is used by default,
47   unless either override mechanism is used.
48
49   - .Values.global.repositoryCred  : override default docker registry credential
50   - .Values.repositoryCredOverride : override global and default docker registry credential
51 */}}
52 {{- define "common.repositoryCred" -}}
53   {{- if .Values.repositoryCredOverride -}}
54     {{- printf "%s" .Values.repositoryCredOverride -}}
55   {{- else -}}
56     {{- if  .Values.global -}}
57       {{- if .Values.global.repositoryCred -}}
58         {{- printf "%s" .Values.global.repositoryCred -}}
59       {{- else -}}
60         {{- printf "%s" .Values.repositoryCred -}}
61       {{- end -}}
62     {{- else -}}
63       {{- printf "%s" .Values.repositoryCred -}}
64     {{- end -}}
65   {{- end -}}
66 {{- end -}}
67
68
69 {{/*
70   Define the golbal image pull policy.
71   The value for .Values.imagePullPolicy is used by default,
72   unless either override mechanism is used.
73
74   - .Values.global.imagePullPolicy  : override default pull policy
75   - .Values.imagePullPolicyOverride : override global and default pull policy
76 */}}
77 {{- define "common.pullPolicy" -}}
78   {{- if .Values.imagePullPolicyOverride -}}
79     {{- printf "%s" .Values.imagePullPolicyOverride -}}
80   {{- else -}}
81     {{- if  .Values.global -}}
82       {{- if .Values.global.imagePullPolicy -}}
83         {{- printf "%s" .Values.global.imagePullPolicy -}}
84       {{- else -}}
85         {{- printf "%s" .Values.imagePullPolicy -}}
86       {{- end -}}
87     {{- else -}}
88       {{- printf "%s" .Values.imagePullPolicy -}}
89     {{- end -}}
90   {{- end -}}
91 {{- end -}}
92
93
94 {{/*
95   Resolve the docker registry certificate name.
96   The value for .Values.repositoryCert is used by default,
97   unless either override mechanism is used.
98
99   - .Values.global.repositoryCert  : override default repository certificate
100   - .Values.repositoryCertOverride : override global and default repository certificate
101 */}}
102 {{- define "common.repositorycert" -}}
103   {{- if .Values.repositoryCertOverride -}}
104     {{- printf "%s" .Values.repositoryCertOverride -}}
105   {{- else -}}
106     {{- if  .Values.global -}}
107       {{- if .Values.global.repositoryCert -}}
108         {{- printf "%s" .Values.global.repositoryCert -}}
109       {{- else -}}
110         {{- printf "%s" .Values.repositoryCert -}}
111       {{- end -}}
112     {{- else -}}
113       {{- printf "%s" .Values.repositoryCert -}}
114     {{- end -}}
115   {{- end -}}
116 {{- end -}}
117
118
119
120
121
122
123 {{/*
124 Generate certificates for the docker registry
125 */}}
126 {{- define "common.repository.gen-certs" -}}
127 {{- $altNames := list ( printf "docker.%s" .Values.ingress.hostpostfix ) -}}
128 {{- $ca := genCA "docker-registry-ca" 365 -}}
129 {{- $cert := genSignedCert ( include "nexus.name" . ) nil $altNames 365 $ca -}}
130 tls.crt: {{ $cert.Cert | b64enc }}
131 tls.key: {{ $cert.Key | b64enc }}
132 {{- end -}}