{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ template "nextcloud.fullname" . }}-nextcloud
  labels:
    {{- include "nextcloud.labels"  ( dict "component" "app"  "rootContext" $ ) | nindent 4 }}
  annotations:
    helm.sh/resource-policy: keep
  {{- with .Values.persistence.annotations }}
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  accessModes:
    - {{ .Values.persistence.accessMode | quote }}
  resources:
    requests:
      storage: {{ .Values.persistence.size | quote }}
  {{- with .Values.persistence.storageClass }}
  {{- if (eq "-" .) }}
  storageClassName: ""
  {{- else }}
  storageClassName: "{{ . }}"
  {{- end }}
  {{- end }}
{{- end }}
