{{- include "nplus.init" $ -}}
# The "ptemp" PVC is used to persist temporary data of the nplus components.
# This is used e.g. in nstl, to store accounting.log info to make sure it is not deleted
# during a PODs recreate

{{- if ((.this.storage).ptemp).name }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ required "You have to define a name for the ptemp PVC" ((.this.storage).ptemp).name }}
  {{- if .this.utils.includeNamespace }}
  namespace: {{ .Release.Namespace }}
  {{- end }}
  labels:
    {{- include "nplus.environmentLabels" . | nindent 4 }}
  annotations:
    {{- include "nplus.argoSharedResource" . | nindent 4 }}

spec:
  {{- if ((.this.storage).ptemp).volumeName }}
  # -- You have set storage.ptemp.volumeName,
  # so we add the volumeName here to avoid automatic
  # volume generation and rather use an existing volume
  # to bind to this PVC.
  volumeName: {{ tpl .this.storage.ptemp.volumeName . }}
  # -- set an empty string must be explicitly set otherwise default StorageClass will be set
  # see https://kubernetes.io/docs/concepts/storage/persistent-volumes/
  storageClassName: ""
  {{- else }}
  # -- volumeName: storage.ptemp.volumeName
  # If you set the volumeName, it appears here. You
  # have not done so, so the provisioner for this
  # volume class will pick up this claim and fulfill it.
  {{- $scn := ((.this.storage).ptemp).class }}
  {{- if $scn }}
  storageClassName: {{ $scn | quote }}
  {{- end }}
  {{- end }}
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: {{ required "You have to define a size for the ptemp PVC" ((.this.storage).ptemp).size }}
{{- end }}