{{- if and .Values.persistence.public.enabled (not .Values.persistence.public.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ include "invoiceninja.public.storageName" . }}
  labels: 
    {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: 
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  accessModes:
  {{- if not (empty .Values.persistence.public.accessModes) }}
  {{- range .Values.persistence.public.accessModes }}
    - {{ . | quote }}
  {{- end }}
  {{- else }}
    - {{ .Values.persistence.public.accessMode | quote }}
  {{- end }}
  resources:
    requests:
      storage: {{ .Values.persistence.public.size | quote }}
  {{- include "invoiceninja.public.storageClass" . | nindent 2 }}
  {{- if .Values.persistence.public.dataSource }}
  dataSource: {{- include "common.tplvalues.render" ( dict "value" .Values.persistence.public.dataSource "context" $ ) | nindent 4 }}
  {{- end }}
{{- end }}

---
{{- if and .Values.persistence.storage.enabled (not .Values.persistence.storage.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ include "invoiceninja.storage.storageName" . }}
  labels: 
    {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: 
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  accessModes:
  {{- if not (empty .Values.persistence.storage.accessModes) }}
  {{- range .Values.persistence.storage.accessModes }}
    - {{ . | quote }}
  {{- end }}
  {{- else }}
    - {{ .Values.persistence.storage.accessMode | quote }}
  {{- end }}
  resources:
    requests:
      storage: {{ .Values.persistence.storage.size | quote }}
  {{- include "invoiceninja.storage.storageClass" . | nindent 2 }}
  {{- if .Values.persistence.storage.dataSource }}
  dataSource: {{- include "common.tplvalues.render" ( dict "value" .Values.persistence.storage.dataSource "context" $ ) | nindent 4 }}
  {{- end }}
{{- end }}
