_volumes.tpl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {{/* Returns Volumes */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.pod.volumes" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the Pod.
  6. */}}
  7. {{- define "ix.v1.common.lib.pod.volumes" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- range $name, $persistenceValues := $rootCtx.Values.persistence -}}
  11. {{- if $persistenceValues.enabled -}}
  12. {{- $persistence := (mustDeepCopy $persistenceValues) -}}
  13. {{- $_ := set $persistence "shortName" $name -}}
  14. {{- $_ := set $persistence "type" ($persistence.type | default $rootCtx.Values.fallbackDefaults.persistenceType) -}}
  15. {{- $selected := false -}}
  16. {{/* If set to true, define volume */}}
  17. {{- if $persistence.targetSelectAll -}}
  18. {{- $selected = true -}}
  19. {{/* If targetSelector is set, check if pod is selected */}}
  20. {{- else if $persistence.targetSelector -}}
  21. {{- if (mustHas $objectData.shortName (keys $persistence.targetSelector)) -}}
  22. {{- $selected = true -}}
  23. {{- end -}}
  24. {{/* If no targetSelector is set or targetSelectAll, check if pod is primary */}}
  25. {{- else -}}
  26. {{- if $objectData.primary -}}
  27. {{- $selected = true -}}
  28. {{- end -}}
  29. {{- end -}}
  30. {{/* If pod selected */}}
  31. {{- if $selected -}}
  32. {{/* Define the volume based on type */}}
  33. {{- $type := ($persistence.type | default $rootCtx.Values.fallbackDefaults.persistenceType) -}}
  34. {{- if eq "ixVolume" $type -}}
  35. {{- include "ix.v1.common.lib.pod.volume.ixVolume" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  36. {{- else if eq "hostPath" $type -}}
  37. {{- include "ix.v1.common.lib.pod.volume.hostPath" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  38. {{- else if eq "secret" $type -}}
  39. {{- include "ix.v1.common.lib.pod.volume.secret" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  40. {{- else if eq "configmap" $type -}}
  41. {{- include "ix.v1.common.lib.pod.volume.configmap" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  42. {{- else if eq "emptyDir" $type -}}
  43. {{- include "ix.v1.common.lib.pod.volume.emptyDir" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  44. {{- else if eq "device" $type -}}
  45. {{- include "ix.v1.common.lib.pod.volume.device" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  46. {{- else if (mustHas $type (list "smb-pv-pvc" "nfs-pv-pvc" "ix-zfs-pvc" "pvc")) -}}
  47. {{- include "ix.v1.common.lib.pod.volume.pvc" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  48. {{- end -}}
  49. {{- end -}}
  50. {{- end -}}
  51. {{- end -}}
  52. {{- end -}}