Improve oran_oom helm charts
[it/dep.git] / smo-install / oran_oom / ric-common / templates / _tiller.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 {{- define "recursiveprinter" -}}
19   {{- $ctx := .ctx }}
20   {{- $printkeys := .printkeys }}
21   {{- $currentkey := first $printkeys -}}
22   {{- $restkeys := rest $printkeys -}}
23   {{- if empty $restkeys -}}
24     {{- $result := index $ctx $currentkey -}}
25     {{- if not (empty $result) -}}
26       {{- $result -}}
27     {{- end -}}
28   {{- else -}}
29     {{- with index $ctx $currentkey }}
30       {{- $newctx := dict "ctx" . "printkeys" $restkeys -}}
31       {{- include "recursiveprinter" $newctx -}}
32     {{- end -}}
33   {{- end -}}
34 {{- end -}}
35
36 {{- define "printer" -}}
37   {{- $topctx := .ctx }}
38   {{- if hasKey $topctx.Values "common" }}
39     {{- if hasKey $topctx.Values.common "tillers" }}
40       {{- $ctx := index $topctx.Values.common.tillers .key -}}
41       {{- if not (empty $ctx) -}}
42         {{- $newctx := dict "ctx" $ctx "printkeys" .printkey -}}
43         {{- include "recursiveprinter" $newctx -}}
44       {{- end -}}
45     {{- end -}}
46   {{- end -}}
47 {{- end -}}
48
49
50
51
52 {{- define "common.tillerName" -}}
53   {{- $printkey := list "name" -}}
54   {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
55   {{- default "tiller-deploy" (include "printer" $newctx) -}}
56 {{- end -}}
57
58
59 {{- define "common.tillerNameSpace" -}}
60   {{- $printkey := list "nameSpace" -}}
61   {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
62   {{- default "kube-system" (include "printer" $newctx) -}}
63 {{- end -}}
64
65 {{- define "common.tillerDeployNameSpace" -}}
66   {{- $printkey := list "deployNameSpace" -}}
67   {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
68   {{- default "kube-system" (include "printer" $newctx) -}}
69 {{- end -}}
70
71
72
73 {{- define "common.tillerPort" -}}
74   {{- $printkey := list "port" -}}
75   {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
76   {{- default 44134 (include "printer" $newctx) -}}
77 {{- end -}}
78
79
80
81
82 {{- define "common.tillerTLSVerify" -}}
83   {{- $printkey := list "tls" "verify" -}}
84   {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
85   {{- default false (include "printer" $newctx) -}}
86 {{- end -}}
87
88
89 {{- define "common.tillerTLSAuthenticate" -}}
90   {{- $printkey := list "tls" "authenticate" -}}
91   {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
92   {{- default false (include "printer" $newctx) -}}
93 {{- end -}}
94
95
96 {{- define "common.tillerHelmClientTLSSecret" -}}
97   {{- $tlsverify := include "common.tillerTLSVerify" . }}
98   {{- $tlsauthenticate := include "common.tillerTLSAuthenticate" . }}
99   {{- if or (eq $tlsverify "true") (eq $tlsauthenticate "true") }}
100     {{- $printkey := list "secret" "helmSecretName" -}}
101     {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
102     {{- default "" (include "printer" $newctx) -}}
103   {{- else -}}
104     {{- printf "" -}}
105   {{- end }}
106 {{- end -}}
107
108
109 {{- define "common.serviceaccountname.tiller" -}}
110   {{- $name := ( include "common.tillerName" . ) -}}
111   {{- printf "svcacct-tiller-%s" $name | trunc 63 | trimSuffix "-" -}}
112 {{- end -}}
113
114
115
116 {{- define "common.deploymentname.tiller" -}}
117   {{- $name := ( include "common.tillerName" . ) -}}
118   {{- printf "deployment-tiller-%s" $name | trunc 63 | trimSuffix "-" -}}
119 {{- end -}}
120
121
122 {{- define "common.servicename.tiller" -}}
123   {{- $topctx := .ctx }}
124   {{- if hasKey $topctx.Values "common" }}
125     {{- if hasKey $topctx.Values.common "tillers" }}
126       {{- $ctx := index $topctx.Values.common.tillers .key -}}
127       {{- if not (empty $ctx) -}}
128         {{- if hasKey $ctx "name" -}}
129           {{- $name := include "common.tillerName" . -}}
130           {{- printf "service-tiller-%s" $name | trunc 63 | trimSuffix "-" -}}
131         {{- else -}}
132           {{ "tiller-deploy" }}
133         {{- end -}}
134       {{- else -}}
135         {{ "tiller-deploy" }}
136       {{- end -}}
137     {{- else -}}
138       {{ "tiller-deploy" }}
139     {{- end -}}
140   {{- else -}}
141     {{ "tiller-deploy" }}
142   {{- end -}}
143 {{- end -}}
144
145 {{- define "common.tillerEndpoint" -}}
146   {{- $servicename := ( include "common.servicename.tiller" . ) -}}
147   {{- $deploynamespace :=  ( include "common.tillerDeployNameSpace" . ) -}}
148   {{- printf "%s.%s" $servicename $deploynamespace -}}
149 {{- end -}}