{{- $vals := .Values }}
{{- range $class := .Values.storageClasses }}
{{- if $class.enabled }}
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: {{ $class.name }}
  annotations:
    "helm.sh/hook": post-install
    "helm.sh/hook-weight": "-5"
    {{- if $class.isDefault }}storageclass.kubernetes.io/is-default-class: "true"{{ end }}
provisioner: {{ $vals.provisionerName }}
reclaimPolicy: {{ $class.reclaimPolicy }}
volumeBindingMode: {{ $class.volumeBindingMode }}
allowVolumeExpansion: {{ $class.allowVolumeExpansion }}
mountOptions:
  {{- toYaml ($class.mountOptions | default (list)) | nindent 2 }}
parameters:
  csi.storage.k8s.io/fstype: {{ $class.fsType | default "ext4" }}
  thinProvision: {{ $class.thinProvision | default "false" | toString | quote }}
  formatOptions: {{ ($class.formatOptions | default (list)) | join " " | quote }}
  copyOnWrite: {{ $class.copyOnWrite | default "false" | toString | quote }}
  freezeFs: {{ $class.freezeFs | default "false" | toString | quote }}
---
{{- end }}
{{- end }}
