_volumes.tpl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. {{- include "ix.v1.common.lib.persistence.validation" (dict "rootCtx" $rootCtx "objectData" $persistence) -}}
  16. {{- $selected := false -}}
  17. {{/* If set to true, define volume */}}
  18. {{- if $persistence.targetSelectAll -}}
  19. {{- $selected = true -}}
  20. {{/* If targetSelector is set, check if pod is selected */}}
  21. {{- else if $persistence.targetSelector -}}
  22. {{- if (mustHas $objectData.shortName (keys $persistence.targetSelector)) -}}
  23. {{- $selected = true -}}
  24. {{- end -}}
  25. {{/* If no targetSelector is set or targetSelectAll, check if pod is primary */}}
  26. {{- else -}}
  27. {{- if $objectData.primary -}}
  28. {{- $selected = true -}}
  29. {{- end -}}
  30. {{- end -}}
  31. {{/* If pod selected */}}
  32. {{- if $selected -}}
  33. {{/* Define the volume based on type */}}
  34. {{- $type := ($persistence.type | default $rootCtx.Values.fallbackDefaults.persistenceType) -}}
  35. {{- if eq "ixVolume" $type -}}
  36. {{- include "ix.v1.common.lib.pod.volume.ixVolume" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  37. {{- else if eq "hostPath" $type -}}
  38. {{- include "ix.v1.common.lib.pod.volume.hostPath" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  39. {{- else if eq "secret" $type -}}
  40. {{- include "ix.v1.common.lib.pod.volume.secret" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  41. {{- else if eq "configmap" $type -}}
  42. {{- include "ix.v1.common.lib.pod.volume.configmap" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  43. {{- else if eq "emptyDir" $type -}}
  44. {{- include "ix.v1.common.lib.pod.volume.emptyDir" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  45. {{- else if eq "device" $type -}}
  46. {{- include "ix.v1.common.lib.pod.volume.device" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
  47. {{- end -}}
  48. {{- end -}}
  49. {{- end -}}
  50. {{- end -}}
  51. {{- end -}}