Skip to content

Commit 0f7d63c

Browse files
committed
Split up _helpers.tpl into smaller, more maintainable files
1 parent fab4609 commit 0f7d63c

File tree

10 files changed

+292
-294
lines changed

10 files changed

+292
-294
lines changed

charts/sourcegraph/templates/_helpers.tpl

Lines changed: 0 additions & 294 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "sourcegraph.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create chart name and version as used by the chart label.
10+
*/}}
11+
{{- define "sourcegraph.chart" -}}
12+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
13+
{{- end }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{{- define "sourcegraph.databaseAuth" -}}
2+
{{- $top := index . 0 -}}
3+
{{- $service := index . 1 -}}
4+
{{- $prefix := index . 2 -}}
5+
{{- $secretName := (index $top.Values $service "name") -}}
6+
{{- $secretName := printf "%s-auth" $secretName -}}
7+
{{- if (index $top.Values $service "auth" "existingSecret") }}{{- $secretName = (index $top.Values $service "auth" "existingSecret") }}{{- end -}}
8+
- name: {{ printf "%sDATABASE" $prefix }}
9+
valueFrom:
10+
secretKeyRef:
11+
key: database
12+
name: {{ $secretName }}
13+
- name: {{ printf "%sHOST" $prefix }}
14+
valueFrom:
15+
secretKeyRef:
16+
key: host
17+
name: {{ $secretName }}
18+
- name: {{ printf "%sPASSWORD" $prefix }}
19+
valueFrom:
20+
secretKeyRef:
21+
key: password
22+
name: {{ $secretName }}
23+
- name: {{ printf "%sPORT" $prefix }}
24+
valueFrom:
25+
secretKeyRef:
26+
key: port
27+
name: {{ $secretName }}
28+
- name: {{ printf "%sUSER" $prefix }}
29+
valueFrom:
30+
secretKeyRef:
31+
key: user
32+
name: {{ $secretName }}
33+
- name: {{ printf "%sSSLMODE" $prefix }}
34+
valueFrom:
35+
secretKeyRef:
36+
key: sslmode
37+
name: {{ $secretName }}
38+
{{- end }}
39+
40+
41+
{{- define "sourcegraph.dataSource" -}}
42+
{{- $top := index . 0 -}}
43+
{{- $service := index . 1 -}}
44+
{{- $secretName := (index $top.Values $service "name") -}}
45+
{{- $secretName := printf "%s-auth" $secretName -}}
46+
{{- if (index $top.Values $service "auth" "existingSecret") }}{{- $secretName = (index $top.Values $service "auth" "existingSecret") }}{{- end -}}
47+
- name: DATA_SOURCE_DB
48+
valueFrom:
49+
secretKeyRef:
50+
key: database
51+
name: {{ $secretName }}
52+
- name: DATA_SOURCE_PASS
53+
valueFrom:
54+
secretKeyRef:
55+
key: password
56+
name: {{ $secretName }}
57+
- name: DATA_SOURCE_PORT
58+
valueFrom:
59+
secretKeyRef:
60+
key: port
61+
name: {{ $secretName }}
62+
- name: DATA_SOURCE_USER
63+
valueFrom:
64+
secretKeyRef:
65+
key: user
66+
name: {{ $secretName }}
67+
- name: DATA_SOURCE_URI
68+
value: "localhost:$(DATA_SOURCE_PORT)/$(DATA_SOURCE_DB)?sslmode=disable"
69+
{{- end }}
70+
71+
72+
{{- define "sourcegraph.authChecksum" -}}
73+
{{- $checksum := list .Values.codeInsightsDB.auth -}}
74+
{{- $checksum = append $checksum .Values.codeIntelDB.auth -}}
75+
{{- $checksum = append $checksum .Values.pgsql.auth -}}
76+
checksum/auth: {{ toJson $checksum | sha256sum }}
77+
{{- end -}}

0 commit comments

Comments
 (0)