{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ template "tomcat.fullname" . }}
  labels: {{- include "tomcat.labels" . | nindent 4 }}
  annotations:
    volume.alpha.kubernetes.io/storage-class: {{ ternary "default" (trimPrefix "storageClassName: " (include "tomcat.storageClass" .)) (empty (include "tomcat.storageClass" .)) }}
spec:
  accessModes:
  {{- range .Values.persistence.accessModes }}
    - {{ . | quote }}
  {{- end }}
  resources:
    requests:
      storage: {{ .Values.persistence.size | quote }}
  {{ include "tomcat.storageClass" . }}
{{- end -}}
