c662cf53eb13489e5f7d71963991dbec89746d7b
[it/dep.git] / ric-platform / 50-RIC-Platform / helm / common / templates / _helmrepo.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 helm repository.
20   The value for .Values.helmRepository is used by default,
21   unless either override mechanism is used.
22
23   - .Values.global.helmRepository  : override default helm repository for all components that use helm
24   - .Values.helmRepositoryOverride : override global and default helm repository on a per component base
25 */}}
26 {{- define "common.helmrepository" -}}
27   {{- if .Values.helmRepositoryOverride -}}
28     {{- printf "%s" .Values.helmRepositoryOverride -}}
29   {{- else -}}
30     {{- if  .Values.global -}}
31       {{- if .Values.global.helmRepository -}}
32         {{- printf "%s" .Values.global.helmRepository -}}
33       {{- else -}}
34         {{- printf "%s" .Values.helmRepository -}}
35       {{- end -}}
36     {{- else -}}
37       {{- printf "%s" .Values.helmRepository -}}
38     {{- end -}}
39   {{- end -}}
40 {{- end -}}
41
42
43 {{/*
44   Resolve the helm repository secret token.
45   The secret token should be installed by K8S system admin.
46   The value for .Values.helmRepositoryCred is used by default,
47   unless either override mechanism is used.
48
49   - .Values.global.helmRepositoryCred  : override default helm repository credential
50   - .Values.helmRepositoryCredOverride : override global and default helm repository credential
51 */}}
52 {{- define "common.helmrepositorycred" -}}
53   {{- if .Values.helmRepositoryCredOverride -}}
54     {{- printf "%s" .Values.helmRepositoryCredOverride -}}
55   {{- else -}}
56     {{- if  .Values.global -}}
57       {{- if .Values.global.helmRepositoryCred -}}
58         {{- printf "%s" .Values.global.helmRepositoryCred -}}
59       {{- else -}}
60         {{- printf "%s" .Values.helmRepositoryCred -}}
61       {{- end -}}
62     {{- else -}}
63       {{- printf "%s" .Values.helmRepositoryCred -}}
64     {{- end -}}
65   {{- end -}}
66 {{- end -}}
67
68 {{/*
69   Resolve the helm repository certificate.
70   The certificate should be installed by K8S system admin.
71   The value for .Values.helmRepositoryCert is used by default,
72   unless either override mechanism is used.
73
74   - .Values.global.helmrepositoryCert  : override default helm repository certificate
75   - .Values.helmRepositoryCertOverride : override global and default helm repository certificate
76 */}}
77 {{- define "common.helmrepositorycert" -}}
78   {{- if .Values.helmRepositoryCertOverride -}}
79     {{- printf "%s" .Values.helmRepositoryCertOverride -}}
80   {{- else -}}
81     {{- if  .Values.global -}}
82       {{- if .Values.global.helmRepositoryCert -}}
83         {{- printf "%s" .Values.global.helmRepositoryCert -}}
84       {{- else -}}
85         {{- printf "%s" .Values.helmRepositoryCert -}}
86       {{- end -}}
87     {{- else -}}
88       {{- printf "%s" .Values.helmRepositoryCert -}}
89     {{- end -}}
90   {{- end -}}
91 {{- end -}}
92
93
94 {{/*
95   Resolve the helm repository tiller service name.
96   The tiller should be installed by K8S system admin.
97   The value for .Values.helmRepositoryTiller is used by default,
98   unless either override mechanism is used.
99
100   - .Values.global.helmrepositoryTiller  : override default helm repository tiller
101   - .Values.helmRepositoryTillerOverride : override global and default helm repository tiller
102 */}}
103 {{- define "common.helmrepositorytiller" -}}
104   {{- if .Values.helmRepositoryTillerOverride -}}
105     {{- printf "%s" .Values.helmRepositoryTillerOverride -}}
106   {{- else -}}
107     {{- if  .Values.global -}}
108       {{- if .Values.global.helmRepositoryTiller -}}
109         {{- printf "%s" .Values.global.helmRepositoryTiller -}}
110       {{- else -}}
111         {{- printf "%s" .Values.helmRepositoryTiller -}}
112       {{- end -}}
113     {{- else -}}
114       {{- printf "%s" .Values.helmRepositoryTiller -}}
115     {{- end -}}
116   {{- end -}}
117 {{- end -}}
118
119
120 {{/*
121   Resolve the helm repository tiller service namespace.
122   The tiller should be installed by K8S system admin.
123   The value for .Values.helmRepositoryTillerNamespace is used by default,
124   unless either override mechanism is used.
125
126   - .Values.global.helmrepositoryTillerNamespace  : override default helm repository tiller namespace
127   - .Values.helmRepositoryTillerNamespaceOverride : override global and default helm repository tiller namespace
128 */}}
129 {{- define "common.helmrepositorytillernamespace" -}}
130   {{- if .Values.helmRepositoryTillerNamespaceOverride -}}
131     {{- printf "%s" .Values.helmRepositoryTillerNamespaceOverride -}}
132   {{- else -}}
133     {{- if  .Values.global -}}
134       {{- if .Values.global.helmRepositoryTillerNamespace -}}
135         {{- printf "%s" .Values.global.helmRepositoryTillerNamespace -}}
136       {{- else -}}
137         {{- printf "%s" .Values.helmRepositoryTillerNamespace -}}
138       {{- end -}}
139     {{- else -}}
140       {{- printf "%s" .Values.helmRepositoryTillerNamespace -}}
141     {{- end -}}
142   {{- end -}}
143 {{- end -}}
144
145
146 {{/*
147   Resolve the helm repository tiller service port.
148   The tiller should be installed by K8S system admin.
149   The value for .Values.helmRepositoryTillerPort is used by default,
150   unless either override mechanism is used.
151
152   - .Values.global.helmrepositoryTillerPort  : override default helm repository tiller port
153   - .Values.helmRepositoryTillerPortOverride : override global and default helm repository tiller port
154 */}}
155 {{- define "common.helmrepositorytillerport" -}}
156   {{- if .Values.helmRepositoryTillerPortOverride -}}
157     {{- printf "%.0f" .Values.helmRepositoryTillerPortOverride -}}
158   {{- else -}}
159     {{- if  .Values.global -}}
160       {{- if .Values.global.helmRepositoryTillerPort -}}
161         {{- printf "%.0f" .Values.global.helmRepositoryTillerPort -}}
162       {{- else -}}
163         {{- printf "%.0f" .Values.helmRepositoryTillerPort -}}
164       {{- end -}}
165     {{- else -}}
166       {{- printf "%.0f" .Values.helmRepositoryTillerPort -}}
167     {{- end -}}
168   {{- end -}}
169 {{- end -}}
170
171 {{/*
172 Generate certificates for the helm repo
173 */}}
174 {{- define "common.helmrepository.gen-certs" -}}
175 {{- $altNames := list ( printf "helm.%s" .Values.ingress.hostpostfix ) -}}
176 {{- $ca := genCA "helm-repository-ca" 365 -}}
177 {{- $cert := genSignedCert ( include "nexus.name" . ) nil $altNames 365 $ca -}}
178 tls.crt: {{ $cert.Cert | b64enc }}
179 tls.key: {{ $cert.Key | b64enc }}
180 {{- end -}}
181