{{- $namespace := .Release.Namespace -}}
{{- $scope := $ -}}
{{- range .Values.application.manifest }}
{{- if $.Values.isGenerateCachePVC }}
{{- if .config -}}
{{- if .config.pvc }}
{{- $applicationName := .name | trunc 63 }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ $applicationName }}-cache
  namespace: {{ $namespace }}
  labels:
    cmii.type: {{ $.Values.application.type }}
    {{- if .modules  }}
    cmii.modules: {{ .modules }}
    {{- end }}
    cmii.app: {{ $applicationName }}
    helm.sh/chart: {{ include "uavcloud-be-core.chart" $scope }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
    {{- if $.Chart.AppVersion }}
    app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
    {{- end }}
    app.kubernetes.io/app-version: {{ $.Values.global.image.tag | quote }}

spec:
  storageClassName: {{ $.Values.global.pvc.storageClass }}
  accessModes:
    - {{ .config.pvc.cache.accessMode }}
  volumeMode: Filesystem
  resources:
    requests:
      storage: {{ .config.pvc.cache.size }}
---
{{- end }}
{{- end }}
{{- end }}
{{- end }}

