_appStorage.tpl 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. {{ if $avm.readOnly }}
  19. readOnly: {{ $avm.readOnly }}
  20. {{ end }}
  21. {{- end -}}
  22. {{ end }}
  23. {{- end -}}
  24. {{- end -}}
  25. {{/*
  26. Define hostPath for appVolumes
  27. */}}
  28. {{- define "common.storage.configureAppVolumes" -}}
  29. {{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "appVolumeMounts")) -}}
  30. {{- $values := . -}}
  31. {{- if $values.appVolumeMounts -}}
  32. {{- range $name, $av := $values.appVolumeMounts -}}
  33. {{ if (default true $av.enabled) }}
  34. - name: {{ $name }}
  35. {{ if or $av.emptyDir $.emptyDirVolumes }}
  36. emptyDir: {}
  37. {{- else -}}
  38. hostPath:
  39. {{ if $av.hostPathEnabled }}
  40. path: {{ required "hostPath not set" $av.hostPath }}
  41. {{ else }}
  42. {{- include "common.schema.validateKeys" (dict "values" $values "checkKeys" (list "ixVolumes")) -}}
  43. {{- include "common.schema.validateKeys" (dict "values" $av "checkKeys" (list "datasetName")) -}}
  44. {{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $values.ixVolumes -}}
  45. path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }}
  46. {{ end }}
  47. {{ end }}
  48. {{ end }}
  49. {{- end -}}
  50. {{- end -}}
  51. {{- end -}}
  52. {{/*
  53. Get all volumes configuration
  54. */}}
  55. {{- define "common.storage.allAppVolumes" -}}
  56. {{- $appVolumeMounts := .appVolumeMounts -}}
  57. {{- if $appVolumeMounts -}}
  58. volumes: {{- include "common.storage.configureAppVolumes" . | nindent 2 -}}
  59. {{- end -}}
  60. {{- end -}}
  61. {{/*
  62. Get all container volume mounts configuration
  63. */}}
  64. {{- define "common.storage.allContainerVolumeMounts" -}}
  65. {{- $appVolumeMounts := .appVolumeMounts -}}
  66. {{- if $appVolumeMounts -}}
  67. volumeMounts: {{- include "common.storage.configureAppVolumeMountsInContainer" . | nindent 2 -}}
  68. {{- end -}}
  69. {{- end -}}