{{ if and .Values.persistence.data.enabled (not .Values.persistence.data.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ include "mattermost-team-edition.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "mattermost-team-edition.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "mattermost-team-edition.chart" . }}
  annotations:
  {{ range $key, $value := .Values.persistence.data.annotations }}
    {{ $key }}: {{ $value | quote }}
  {{ end }}
spec:
  accessModes:
  - {{ .Values.persistence.data.accessMode | quote }}
  resources:
    requests:
      storage: {{ .Values.persistence.data.size | quote }}
{{ if .Values.persistence.data.storageClass }}
{{ if (eq "-" .Values.persistence.data.storageClass) }}
  storageClassName: ""
{{ else }}
  storageClassName: "{{ .Values.persistence.data.storageClass }}"
{{ end }}
{{ end }}
{{ end }}
