Skip to content

Commit 45ea308

Browse files
committed
Support downloading integrations by URL (#2)
Closes #2
1 parent dbe5e3b commit 45ea308

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

backend/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: backend
3-
version: 0.3.0
3+
version: 0.4.0
44
description: Backend of the Snoty application suite
55
type: application
66
home: https://snoty.me

backend/templates/deployment.yaml

+24-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,26 @@ spec:
1717
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
1818
annotations:
1919
snoty.me/checksum-config: {{ include "snoty.config" . | sha256sum }}
20+
snoty.me/checksum-scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
21+
2022
{{- if .Values.podAnnotations }}
2123
{{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
2224
{{- end }}
2325
spec:
26+
initContainers:
27+
{{- if .Values.download.integrations }}
28+
- name: download-integrations
29+
image: alpine:3.20
30+
volumeMounts:
31+
- name: scripts
32+
mountPath: /scripts
33+
- name: integrations
34+
mountPath: /integrations
35+
command:
36+
- sh
37+
- -c
38+
- "cd /scripts && ./download-integrations.sh"
39+
{{- end }}
2440
containers:
2541
- name: {{ include "common.names.fullname" . }}
2642
image: {{ template "snoty.image" . }}
@@ -48,6 +64,8 @@ spec:
4864
- mountPath: /app/application.yml
4965
name: app-config
5066
subPath: application.yml
67+
- name: integrations
68+
mountPath: /integrations
5169
{{- if .Values.customStartupProbe }}
5270
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }}
5371
{{- else if .Values.startupProbe.enabled }}
@@ -91,5 +109,9 @@ spec:
91109
- name: app-config
92110
configMap:
93111
name: {{ include "common.names.fullname" . }}
94-
95-
112+
- name: scripts
113+
configMap:
114+
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
115+
defaultMode: 0755
116+
- name: integrations
117+
emptyDir:
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "common.names.fullname" . }}-scripts
5+
namespace: {{ .Release.Namespace | quote }}
6+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
7+
{{- if .Values.commonAnnotations }}
8+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
9+
{{- end }}
10+
data:
11+
integrations.json: {{ toJson .Values.download.integrations | quote }}
12+
download-integrations.sh: |-
13+
echo "Installing jq..."
14+
apk add --no-cache jq
15+
echo "Finished installing jq!"
16+
echo "Downloading integrations..."
17+
echo "Raw input: $(cat integrations.json)"
18+
# wget every integration
19+
jq -r '.[]' integrations.json | while read -r integration; do
20+
echo "Downloading $integration..."
21+
# integrations are picked up in /integrations by JIB
22+
if wget "$integration" -P /integrations; then
23+
echo "Finished downloading $integration!"
24+
else
25+
echo "Error downloading $integration!"
26+
if {{ .Values.download.errorOnDownloadFail }}; then
27+
echo "[debug] errorOnDownloadFail is set to true, exiting..."
28+
exit 1
29+
fi
30+
fi
31+
done

backend/values.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ extraAppConfig: {}
129129

130130
extraEnvVars: []
131131

132+
download:
133+
## @param download.errorOnDownloadFail whether to fail when any integration fails to download
134+
errorOnDownloadFail: true
135+
## @param download.integrations a list of integrations (HTTP(s) URLs) to download and start snoty with
136+
integrations: []
137+
132138
## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/
133139
##
134140
ingress:
@@ -241,6 +247,8 @@ mongodb:
241247
rootPassword: changeme
242248
architecture: standalone
243249
service:
250+
# you may want to change this to `releasename-mongodb`
251+
# TODO: figure out what happened here
244252
nameOverride: snoty-mongodb
245253
# --- HA ---
246254
# architecture: replicaset

0 commit comments

Comments
 (0)