-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_helpers.tpl
174 lines (161 loc) · 4.96 KB
/
_helpers.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{{/*
Expand the name of the chart.
*/}}
{{- define "wallarm-sidecar.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "wallarm-sidecar.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "wallarm-sidecar.labels" -}}
{{ include "wallarm-sidecar.selectorLabels" . }}
app.kubernetes.io/app: {{ template "wallarm-sidecar.name" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
{{- if .Values.extraLabels }}
{{- .Values.extraLabels | toYaml }}
{{- end }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "wallarm-sidecar.selectorLabels" -}}
app.kubernetes.io/name: {{ include "wallarm-sidecar.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Basic annotations
*/}}
{{- define "wallarm-sidecar.annotations" -}}
{{- if .Values.extraAnnotations }}
{{- .Values.extraAnnotations | toYaml }}
{{- end }}
{{- end }}
{{/*
Create the name of the service account for postanalytics
*/}}
{{- define "wallarm-sidecar.postanalytics.serviceAccountName" -}}
{{- if .Values.postanalytics.serviceAccount.create -}}
{{- include "wallarm-sidecar.fullname" . }}-postanalytics
{{- else -}}
{{- .Values.postanalytics.serviceAccount.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account for controller
*/}}
{{- define "wallarm-sidecar.controller.serviceAccountName" -}}
{{- if .Values.controller.serviceAccount.create -}}
{{- include "wallarm-sidecar.fullname" . }}-controller
{{- else -}}
{{- .Values.controller.serviceAccount.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{/*
Gives name of image to use
*/}}
{{- define "wallarm-sidecar.image" -}}
{{- if .fullname -}}
{{- .fullname -}}
{{- else -}}
{{- if .registry -}}
{{- printf "%s/%s:%s" .registry .image .tag -}}
{{- else -}}
{{- printf "%s:%s" .image .tag -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "wallarm-sidecar.credentials" -}}
- name: WALLARM_API_HOST
valueFrom:
secretKeyRef:
key: WALLARM_API_HOST
name: {{ template "wallarm-sidecar.fullname" . }}-credentials
- name: WALLARM_API_PORT
valueFrom:
secretKeyRef:
key: WALLARM_API_PORT
name: {{ template "wallarm-sidecar.fullname" . }}-credentials
- name: WALLARM_API_USE_SSL
valueFrom:
secretKeyRef:
key: WALLARM_API_USE_SSL
name: {{ template "wallarm-sidecar.fullname" . }}-credentials
- name: WALLARM_API_CA_VERIFY
valueFrom:
secretKeyRef:
key: WALLARM_API_CA_VERIFY
name: {{ template "wallarm-sidecar.fullname" . }}-credentials
- name: WALLARM_LABELS
valueFrom:
secretKeyRef:
key: WALLARM_LABELS
name: {{ template "wallarm-sidecar.fullname" . }}-credentials
- name: WALLARM_API_TOKEN
valueFrom:
secretKeyRef:
{{- $existingSecret := index .Values.config.wallarm.api "existingSecret" | default dict }}
{{- if $existingSecret.enabled }}
key: {{ $existingSecret.secretKey }}
name: {{ $existingSecret.secretName }}
{{- else }}
key: WALLARM_API_TOKEN
name: {{ template "wallarm-sidecar.fullname" . }}-credentials
{{- end }}
{{- end -}}
{{/*
The name of Wallarm component
*/}}
{{- define "wallarm-sidecar.componentName" -}}
wallarm-sidecar-proxy
{{- end -}}
{{- define "wallarm-sidecar.version" -}}
- name: WALLARM_COMPONENT_NAME
value: {{ template "wallarm-sidecar.componentName" . }}
- name: WALLARM_COMPONENT_VERSION
value: {{ .Chart.Version | quote }}
{{- end -}}
{{- define "wallarm-sidecar.wstoreHost" -}}
{{- if .Values.postanalytics.external.enabled }}
{{- required "Hostname of external Wstore instance is required" .Values.postanalytics.external.host }}
{{- else }}
{{- template "wallarm-sidecar.fullname" . }}-postanalytics.{{ .Release.Namespace }}.svc
{{- end }}
{{- end -}}
{{- define "wallarm-sidecar.wstorePort" -}}
{{- if .Values.postanalytics.external.enabled }}
{{- required "Port of external Wstore instance is required" .Values.postanalytics.external.port }}
{{- else }}
{{- .Values.postanalytics.service.port }}
{{- end }}
{{- end -}}
{{/*
Wcli arguments building
*/}}
{{- define "wallarm-sidecar.wcli-args" -}}
"-log-level", "{{ .Values.config.wcli.logLevel }}",{{ " " }}
{{- with .Values.config.wcli.commands -}}
{{- range $name, $value := . -}}
"job:{{ $name }}", "-log-level", "{{ $value.logLevel }}",{{ " " }}
{{- end -}}
{{- end -}}
{{- end -}}