---
{{- if .Values.persistentVolume.enabled -}}
{{- if not .Values.persistentVolume.existingClaim -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  {{- if .Values.persistentVolume.annotations }}
  annotations:
{{ toYaml .Values.persistentVolume.annotations | indent 4 }}
  {{- end }}
  labels:
    {{- include "ollama.labels" . | nindent 4 }}
  name: {{ template "ollama.fullname" . }}
  namespace: {{ include "ollama.namespace" . }}
spec:
  accessModes:
{{ toYaml .Values.persistentVolume.accessModes | indent 4 }}
{{- if .Values.persistentVolume.storageClass }}
{{- if (eq "-" .Values.persistentVolume.storageClass) }}
  storageClassName: ""
{{- else }}
  storageClassName: "{{ .Values.persistentVolume.storageClass }}"
{{- end }}
{{- end }}
{{- if .Values.persistentVolume.volumeMode }}
  volumeMode: "{{ .Values.persistentVolume.volumeMode }}"
{{- end }}
{{- if .Values.persistentVolume.volumeName }}
  volumeName: "{{ .Values.persistentVolume.volumeName }}"
{{- end }}
  resources:
    requests:
      storage: "{{ .Values.persistentVolume.size }}"
{{- end -}}
{{- end -}}
