1 ################################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property. #
3 # Copyright (c) 2019 Nokia. #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 ################################################################################
18 {{- define "recursiveprinter" -}}
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) -}}
29 {{- with index $ctx $currentkey }}
30 {{- $newctx := dict "ctx" . "printkeys" $restkeys -}}
31 {{- include "recursiveprinter" $newctx -}}
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 -}}
52 {{- define "common.tillerName" -}}
53 {{- $printkey := list "name" -}}
54 {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
55 {{- default "tiller-deploy" (include "printer" $newctx) -}}
59 {{- define "common.tillerNameSpace" -}}
60 {{- $printkey := list "nameSpace" -}}
61 {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
62 {{- default "kube-system" (include "printer" $newctx) -}}
65 {{- define "common.tillerDeployNameSpace" -}}
66 {{- $printkey := list "deployNameSpace" -}}
67 {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
68 {{- default "kube-system" (include "printer" $newctx) -}}
73 {{- define "common.tillerPort" -}}
74 {{- $printkey := list "port" -}}
75 {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
76 {{- default 44134 (include "printer" $newctx) -}}
82 {{- define "common.tillerTLSVerify" -}}
83 {{- $printkey := list "tls" "verify" -}}
84 {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
85 {{- default false (include "printer" $newctx) -}}
89 {{- define "common.tillerTLSAuthenticate" -}}
90 {{- $printkey := list "tls" "authenticate" -}}
91 {{- $newctx := dict "ctx" .ctx "key" .key "printkey" $printkey }}
92 {{- default false (include "printer" $newctx) -}}
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) -}}
109 {{- define "common.serviceaccountname.tiller" -}}
110 {{- $name := ( include "common.tillerName" . ) -}}
111 {{- printf "svcacct-tiller-%s" $name | trunc 63 | trimSuffix "-" -}}
116 {{- define "common.deploymentname.tiller" -}}
117 {{- $name := ( include "common.tillerName" . ) -}}
118 {{- printf "deployment-tiller-%s" $name | trunc 63 | trimSuffix "-" -}}
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 "-" -}}
132 {{ "tiller-deploy" }}
135 {{ "tiller-deploy" }}
138 {{ "tiller-deploy" }}
141 {{ "tiller-deploy" }}
145 {{- define "common.tillerEndpoint" -}}
146 {{- $servicename := ( include "common.servicename.tiller" . ) -}}
147 {{- $deploynamespace := ( include "common.tillerDeployNameSpace" . ) -}}
148 {{- printf "%s.%s" $servicename $deploynamespace -}}