{{- if .Values.snapshotsEnabled }}

{{- if typeIs "[]interface {}" .Values.configuration.volumeSnapshotLocation }}
{{- range .Values.configuration.volumeSnapshotLocation }}
---
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
  name: {{ .name | default "default" }}
  namespace: {{ $.Release.Namespace }}
  {{- with .annotations }}
  annotations:
    {{- range $key, $value := . }}
    {{- $key | nindent 4 }}: {{ $value | quote }}
    {{- end }}
  {{- end }}
  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:
  {{- if not (empty .credential) }}
  credential:
    {{- with .credential.name }}
    name: {{ . }}
    {{- end }}
    {{- with .credential.key }}
    key: {{ . }}
    {{- end }}
  {{- end }}
  provider: {{ .provider }}
{{- with .config }}
  config:
{{- range $key, $value := . }}
{{- $key | nindent 4 }}: {{ $value | quote }}
{{- end }}
{{- end -}}
{{- end }}
{{- end }}
{{- end }}
