{{- include "nplus.init" $ -}}
# The "conf" PVC is used to store all config data of the nplus components.
# You may want to use a git repo on this conf store

{{- if ((.this.storage).conf).name }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ required "You have to define a name for the conf PVC" ((.this.storage).conf).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).conf).volumeName }}
  # -- You have set storage.conf.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.conf.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 }}{{/* if ((.this.storage).conf).volumeName */}}
  # -- volumeName: storage.conf.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).conf).class }}
  {{- if $scn }}
  storageClassName: {{ $scn | quote }}
  {{- end }}
  {{- end }}{{/* if ((.this.storage).conf).volumeName else */}}
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: {{ required "You have to define a size for the conf PVC" ((.this.storage).conf).size }}
{{- end }}{{/* if ((.this.storage).conf).name */}}