_device.tpl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. {{/* Returns device (hostPath) Volume */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.pod.volume.device" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the volume.
  6. */}}
  7. {{- define "ix.v1.common.lib.pod.volume.device" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $hostPathType := "" -}}
  11. {{- if $objectData.hostPathType -}}
  12. {{- $hostPathType = tpl $objectData.hostPathType $rootCtx -}}
  13. {{- end -}}
  14. {{- if not $objectData.hostPath -}}
  15. {{- fail "Persistence - Expected non-empty <hostPath> on <device> type" -}}
  16. {{- end -}}
  17. {{- $hostPath := tpl $objectData.hostPath $rootCtx -}}
  18. {{- if not (hasPrefix "/" $hostPath) -}}
  19. {{- fail "Persistence - Expected <hostPath> to start with a forward slash [/] on <device> type" -}}
  20. {{- end -}}
  21. {{- $types := (list "DirectoryOrCreate" "Directory" "FileOrCreate" "File" "Socket" "CharDevice" "BlockDevice") -}}
  22. {{- if and $hostPathType (not (mustHas $hostPathType $types)) -}}
  23. {{- fail (printf "Persistence - Expected <hostPathType> to be one of [%s], but got [%s]" (join ", " $types) $hostPathType) -}}
  24. {{- end }}
  25. - name: {{ $objectData.shortName }}
  26. hostPath:
  27. path: {{ $hostPath }}
  28. {{- with $hostPathType }}
  29. type: {{ $hostPathType }}
  30. {{- end -}}
  31. {{- end -}}