_appStorage.tpl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {{/*
  2. Define appVolumeMounts for container
  3. */}}
  4. {{- define "common.storage.configureAppVolumeMountsInContainer" -}}
  5. {{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "appVolumeMounts")) -}}
  6. {{- $appVolumeMounts := .appVolumeMounts -}}
  7. {{- if $appVolumeMounts -}}
  8. {{ range $name, $avm := $appVolumeMounts }}
  9. {{- if (default true $avm.enabled) -}}
  10. {{ if $avm.containerNameOverride }}
  11. {{ $name = $avm.containerNameOverride }}
  12. {{ end }}
  13. - name: {{ $name }}
  14. mountPath: {{ $avm.mountPath }}
  15. {{ if $avm.subPath }}
  16. subPath: {{ $avm.subPath }}
  17. {{ end }}
  18. {{- end -}}
  19. {{ end }}
  20. {{- end -}}
  21. {{- end -}}
  22. {{/*
  23. Define hostPath for appVolumes
  24. */}}
  25. {{- define "common.storage.configureAppVolumes" -}}
  26. {{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "appVolumeMounts")) -}}
  27. {{- $values := . -}}
  28. {{- if $values.appVolumeMounts -}}
  29. {{- range $name, $av := $values.appVolumeMounts -}}
  30. {{ if (default true $av.enabled) }}
  31. - name: {{ $name }}
  32. {{ if or $av.emptyDir $.emptyDirVolumes }}
  33. emptyDir: {}
  34. {{- else -}}
  35. hostPath:
  36. {{ if $av.hostPathEnabled }}
  37. path: {{ required "hostPath not set" $av.hostPath }}
  38. {{ else }}
  39. {{- include "common.schema.validateKeys" (dict "values" $values "checkKeys" (list "ixVolumes")) -}}
  40. {{- include "common.schema.validateKeys" (dict "values" $av "checkKeys" (list "datasetName")) -}}
  41. {{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $values.ixVolumes -}}
  42. path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }}
  43. {{ end }}
  44. {{ end }}
  45. {{ end }}
  46. {{- end -}}
  47. {{- end -}}
  48. {{- end -}}
  49. {{/*
  50. Get all volumes configuration
  51. */}}
  52. {{- define "common.storage.allAppVolumes" -}}
  53. {{- $appVolumeMounts := .appVolumeMounts -}}
  54. {{- if $appVolumeMounts -}}
  55. volumes: {{- include "common.storage.configureAppVolumes" . | nindent 2 -}}
  56. {{- end -}}
  57. {{- end -}}
  58. {{/*
  59. Get all container volume moutns configuration
  60. */}}
  61. {{- define "common.storage.allContainerVolumeMounts" -}}
  62. {{- $appVolumeMounts := .appVolumeMounts -}}
  63. {{- if $appVolumeMounts -}}
  64. volumeMounts: {{- include "common.storage.configureAppVolumeMountsInContainer" . | nindent 2 -}}
  65. {{- end -}}
  66. {{- end -}}