{{/* Make sure all variables are set properly */}}
{{- include "tc.common.loader.init" . }}

{{/* Render configmap for nextcloud */}}
{{- include "nextcloud.configmap" . }}

{{- $newMiddlewares :=  append .Values.ingress.main.fixedMiddlewares "tc-nextcloud-chain" }}
{{- $_ := set .Values.ingress.main "fixedMiddlewares" $newMiddlewares -}}

{{- $_ := set .Values.additionalContainers "nginx" (include "nextcloud.nginx" . | fromYaml) -}}
{{- if .Values.imaginary.enabled -}}
{{- $_ := set .Values.additionalContainers "imaginary" (include "nextcloud.imaginary" . | fromYaml) -}}
{{- end -}}
{{- if .Values.hpb.enabled -}}
{{- $_ := set .Values.additionalContainers "hpb" (include "nextcloud.hpb" . | fromYaml) -}}
{{- end -}}

{{/* Render the templates */}}
{{ include "tc.common.loader.apply" . }}

{{/* Render cronjob for nextcloud */}}
{{- include "nextcloud.cronjob" . }}
