{{- range $component, $data := .Values.backup }}
{{- if ne $component "controlPlane" }}
apiVersion: velero.io/v1
kind: Schedule
metadata:
  name: {{ include "velero.fullname" $ }}-{{ $component | lower }}
  namespace: {{ $.Release.Namespace }}
  annotations:
    "helm.sh/hook": post-install,post-upgrade,post-rollback
    "helm.sh/hook-delete-policy": before-hook-creation
  labels:
    app.kubernetes.io/name: {{ include "velero.name" $ }}
    app.kubernetes.io/instance: {{ $.Release.Name }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
  useOwnerReferencesInBackup: false
  schedule: {{ $data.schedule | squote }}
  template:
    csiSnapshotTimeout: 0s
    includedNamespaces:
      {{- if eq $component "monitoring" }}
      - {{ print "grafana-" $component | quote -}}
      {{ else }}
      - {{ kebabcase $component | quote -}}
      {{ end }}
    ttl: {{ print (mul $data.expires_in_days 24) "h" }}
---
{{- end }}
{{- end }}
