{{- if .Values.backupsEnabled }}
apiVersion: velero.io/v1
kind: BackupStorageLocation
metadata:
  name: {{ include "velero.backupStorageLocation.name" . }}
  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 }}
    helm.sh/chart: {{ include "velero.chart" . }}
spec:
  provider: {{ include "velero.backupStorageLocation.provider" . }}
  {{- with .Values.configuration.backupStorageLocation.default }}
  default: {{ . }}
  {{- end }}
  accessMode: {{ .Values.configuration.backupStorageLocation.accessMode }}
{{- with .Values.configuration.backupStorageLocation }}
  objectStorage:
    bucket: {{ .bucket | quote }}
    {{- with .prefix }}
    prefix: {{ . | quote }}
    {{- end }}
    {{- with .caCert }}
    caCert: {{ . }}
    {{- end }}
{{- with .config }}
  config:
{{- range $key, $value := . }}
{{- $key | nindent 4 }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
