_storageEntry.tpl 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {{/* This is a shim generating yaml that will be passed
  2. to the actual templates later on the process.
  3. For that reason the validation is minimal as the
  4. actual templates will do the validation. */}}
  5. {{/* Call this template:
  6. {{ include "ix.v1.common.app.storageOptions" (dict "storage" $storage) }}
  7. */}}
  8. {{- define "ix.v1.common.app.storageOptions" -}}
  9. {{- $storage := .storage -}}
  10. {{- $size := "" -}}
  11. {{- $hostPath := "" -}}
  12. {{- $datasetName := "" -}}
  13. {{- $readOnly := false -}}
  14. {{- $server := "" -}}
  15. {{- $share := "" -}}
  16. {{- $domain := "" -}}
  17. {{- $username := "" -}}
  18. {{- $password := "" -}}
  19. {{- $medium := "" -}}
  20. {{- if $storage.readOnly -}}
  21. {{- $readOnly = true -}}
  22. {{- end -}}
  23. {{/* hostPath */}}
  24. {{- if eq $storage.type "hostPath" -}}
  25. {{- if not $storage.hostPathConfig -}}
  26. {{- fail (printf "Storage Shim - Expected non-empty [hostPathConfig]") -}}
  27. {{- end -}}
  28. {{- if $storage.hostPathConfig.aclEnable -}}
  29. {{- $hostPath = $storage.hostPathConfig.acl.path -}}
  30. {{- else -}}
  31. {{- $hostPath = $storage.hostPathConfig.hostPath -}}
  32. {{- end -}}
  33. {{- end -}}
  34. {{/* ixVolume */}}
  35. {{- if eq $storage.type "ixVolume" -}}
  36. {{- if not $storage.ixVolumeConfig -}}
  37. {{- fail (printf "Storage Shim - Expected non-empty [ixVolumeConfig]") -}}
  38. {{- end -}}
  39. {{- $datasetName = $storage.ixVolumeConfig.datasetName -}}
  40. {{- end -}}
  41. {{/* SMB Share */}}
  42. {{- if eq $storage.type "smb-pv-pvc" -}}
  43. {{- if not $storage.smbConfig -}}
  44. {{- fail (printf "Storage Shim - Expected non-empty [smbConfig]") -}}
  45. {{- end -}}
  46. {{- $server = $storage.smbConfig.server | quote -}}
  47. {{- $share = $storage.smbConfig.share | quote -}}
  48. {{- $domain = $storage.smbConfig.domain | quote -}}
  49. {{- $username = $storage.smbConfig.username | quote -}}
  50. {{- $password = $storage.smbConfig.password | quote -}}
  51. {{- if $storage.smbConfig.size -}}
  52. {{- $size = (printf "%vGi" $storage.smbConfig.size) -}}
  53. {{- end -}}
  54. {{- end -}}
  55. {{/* emptyDir */}}
  56. {{- if eq $storage.type "emptyDir" -}}
  57. {{- if not $storage.emptyDirConfig -}}
  58. {{- fail (printf "Storage Shim - Expected non-empty [emptyDirConfig]") -}}
  59. {{- end -}}
  60. {{- if $storage.emptyDirConfig.medium -}}
  61. {{- $medium = $storage.emptyDirConfig.medium -}}
  62. {{- end -}}
  63. {{- if $storage.emptyDirConfig.size -}}
  64. {{- $size = (printf "%vGi" $storage.emptyDirConfig.size) -}}
  65. {{- end -}}
  66. {{- end }}
  67. type: {{ $storage.type }}
  68. size: {{ $size }}
  69. hostPath: {{ $hostPath }}
  70. datasetName: {{ $datasetName }}
  71. readOnly: {{ $readOnly }}
  72. medium: {{ $medium }}
  73. server: {{ $server }}
  74. share: {{ $share }}
  75. domain: {{ $domain }}
  76. username: {{ $username }}
  77. password: {{ $password }}
  78. {{- if eq $storage.type "smb-pv-pvc" }}
  79. mountOptions:
  80. - key: noperm
  81. {{- end }}
  82. {{- end -}}