Skip to content

Commit 081b741

Browse files
committed
fix: move volumes to helpers
Signed-off-by: WrenIX <[email protected]>
1 parent 939e5be commit 081b741

File tree

3 files changed

+47
-76
lines changed

3 files changed

+47
-76
lines changed

charts/nextcloud/templates/_helpers.tpl

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,39 @@ Swift as primary object store env vars
343343
{{- end -}}
344344

345345

346+
{{/*
347+
Volumes for a pod, which needs access to nextcloud data.
348+
*/}}
349+
{{- define "nextcloud.volumes" -}}
350+
- name: nextcloud-main
351+
{{- if .Values.persistence.enabled }}
352+
persistentVolumeClaim:
353+
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }}
354+
{{- else }}
355+
emptyDir: {}
356+
{{- end }}
357+
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
358+
- name: nextcloud-data
359+
persistentVolumeClaim:
360+
claimName: {{ if .Values.persistence.nextcloudData.existingClaim }}{{ .Values.persistence.nextcloudData.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud-data{{- end }}
361+
{{- end }}
362+
{{- if .Values.nextcloud.configs }}
363+
- name: nextcloud-config
364+
configMap:
365+
name: {{ template "nextcloud.fullname" . }}-config
366+
{{- end }}
367+
{{- if .Values.nextcloud.phpConfigs }}
368+
- name: nextcloud-phpconfig
369+
configMap:
370+
name: {{ template "nextcloud.fullname" . }}-phpconfig
371+
{{- end }}
372+
{{- with .Values.nextcloud.extraVolumes }}
373+
{{- toYaml . }}
374+
{{- end }}
375+
{{- end -}}
376+
377+
378+
346379
{{/*
347380
Create volume mounts for the nextcloud container as well as the cron sidecar container.
348381
*/}}
@@ -374,11 +407,13 @@ Create volume mounts for the nextcloud container as well as the cron sidecar con
374407
- name: nextcloud-main
375408
mountPath: /var/www/html/themes
376409
subPath: {{ ternary "themes" (printf "%s/themes" .Values.nextcloud.persistence.subPath) (empty .Values.nextcloud.persistence.subPath) }}
410+
377411
{{- range $key, $value := .Values.nextcloud.configs }}
378412
- name: nextcloud-config
379413
mountPath: /var/www/html/config/{{ $key }}
380414
subPath: {{ $key }}
381-
{{- end }}
415+
{{- end }}{{/* end-range configs */}}
416+
382417
{{- if .Values.nextcloud.configs }}
383418
{{- range $key, $value := .Values.nextcloud.defaultConfigs }}
384419
{{- if $value }}
@@ -387,14 +422,17 @@ Create volume mounts for the nextcloud container as well as the cron sidecar con
387422
subPath: {{ $key }}
388423
{{- end }}
389424
{{- end }}
390-
{{- end }}
391-
{{- if .Values.nextcloud.extraVolumeMounts }}
392-
{{ toYaml .Values.nextcloud.extraVolumeMounts }}
393-
{{- end }}
425+
{{- end }}{{/* end-if .configs (also defaultConfigs beside config, see above) */}}
426+
427+
{{- with .Values.nextcloud.extraVolumeMounts }}
428+
{{ toYaml . }}
429+
{{- end }}{{/* end-with extraVolumes*/}}
430+
394431
{{- $nginxEnabled := .Values.nginx.enabled -}}
395432
{{- range $key, $value := .Values.nextcloud.phpConfigs }}
396433
- name: nextcloud-phpconfig
397434
mountPath: {{ $nginxEnabled | ternary (printf "/usr/local/etc/php-fpm.d/%s" $key | quote) (printf "/usr/local/etc/php/conf.d/%s" $key | quote) }}
398435
subPath: {{ $key }}
399-
{{- end }}
436+
{{- end }}{{/* end-range phpconfig (with nginx) */}}
437+
400438
{{- end -}}

charts/nextcloud/templates/nextcloud-ai-worker.yaml renamed to charts/nextcloud/templates/ai-worker.yaml

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -70,50 +70,7 @@ spec:
7070
{{- toYaml .Values.aiWorker.resources | nindent 12 }}
7171
volumeMounts:
7272
{{- include "nextcloud.volumeMounts" . | trim | nindent 12 }}
73-
{{- range $hook, $shell := .Values.nextcloud.hooks }}
74-
{{- if $shell }}
75-
- name: nextcloud-hooks
76-
mountPath: /docker-entrypoint-hooks.d/{{ $hook }}/helm.sh
77-
subPath: {{ $hook }}.sh
78-
readOnly: true
79-
{{- end }}
80-
{{- end }}
8173
volumes:
82-
- name: nextcloud-main
83-
{{- if .Values.persistence.enabled }}
84-
persistentVolumeClaim:
85-
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }}
86-
{{- else }}
87-
emptyDir: {}
88-
{{- end }}
89-
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
90-
- name: nextcloud-data
91-
persistentVolumeClaim:
92-
claimName: {{ if .Values.persistence.nextcloudData.existingClaim }}{{ .Values.persistence.nextcloudData.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud-data{{- end }}
93-
{{- end }}
94-
{{- if .Values.nextcloud.configs }}
95-
- name: nextcloud-config
96-
configMap:
97-
name: {{ template "nextcloud.fullname" . }}-config
98-
{{- end }}
99-
{{- if .Values.nextcloud.phpConfigs }}
100-
- name: nextcloud-phpconfig
101-
configMap:
102-
name: {{ template "nextcloud.fullname" . }}-phpconfig
103-
{{- end }}
104-
{{- if .Values.nginx.enabled }}
105-
- name: nextcloud-nginx-config
106-
configMap:
107-
name: {{ template "nextcloud.fullname" . }}-nginxconfig
108-
{{- end }}
109-
{{- if not (values .Values.nextcloud.hooks | compact | empty) }}
110-
- name: nextcloud-hooks
111-
configMap:
112-
name: {{ template "nextcloud.fullname" . }}-hooks
113-
defaultMode: 0o755
114-
{{- end }}
115-
{{- with .Values.nextcloud.extraVolumes }}
116-
{{- toYaml . | nindent 8 }}
117-
{{- end }}
74+
{{- include "nextcloud.volumes" . | trim | nindent 8 }}
11875
restartPolicy: Always
119-
{{- end }}
76+
{{- end }}

charts/nextcloud/templates/deployment.yaml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -348,28 +348,7 @@ spec:
348348
{{- toYaml . | nindent 8 }}
349349
{{- end }}
350350
volumes:
351-
- name: nextcloud-main
352-
{{- if .Values.persistence.enabled }}
353-
persistentVolumeClaim:
354-
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }}
355-
{{- else }}
356-
emptyDir: {}
357-
{{- end }}
358-
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
359-
- name: nextcloud-data
360-
persistentVolumeClaim:
361-
claimName: {{ if .Values.persistence.nextcloudData.existingClaim }}{{ .Values.persistence.nextcloudData.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud-data{{- end }}
362-
{{- end }}
363-
{{- if .Values.nextcloud.configs }}
364-
- name: nextcloud-config
365-
configMap:
366-
name: {{ template "nextcloud.fullname" . }}-config
367-
{{- end }}
368-
{{- if .Values.nextcloud.phpConfigs }}
369-
- name: nextcloud-phpconfig
370-
configMap:
371-
name: {{ template "nextcloud.fullname" . }}-phpconfig
372-
{{- end }}
351+
{{- include "nextcloud.volumes" . | trim | nindent 8 }}
373352
{{- if .Values.nginx.enabled }}
374353
- name: nextcloud-nginx-config
375354
configMap:
@@ -381,9 +360,6 @@ spec:
381360
name: {{ template "nextcloud.fullname" . }}-hooks
382361
defaultMode: 0o755
383362
{{- end }}
384-
{{- with .Values.nextcloud.extraVolumes }}
385-
{{- toYaml . | nindent 8 }}
386-
{{- end }}
387363
securityContext:
388364
{{- with .Values.securityContext }}
389365
{{- toYaml . | nindent 8 }}

0 commit comments

Comments
 (0)