_storageEntry.tpl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. {{- $mountOpts := (list
  21. (dict "key" "noperm")
  22. ) -}}
  23. {{- if $storage.readOnly -}}
  24. {{- $readOnly = true -}}
  25. {{- end -}}
  26. {{/* hostPath */}}
  27. {{- if eq $storage.type "hostPath" -}}
  28. {{- if not $storage.hostPathConfig -}}
  29. {{- fail (printf "Storage Shim - Expected non-empty [hostPathConfig]") -}}
  30. {{- end -}}
  31. {{- if $storage.hostPathConfig.aclEnable -}}
  32. {{- $hostPath = $storage.hostPathConfig.acl.path -}}
  33. {{- else -}}
  34. {{- $hostPath = $storage.hostPathConfig.hostPath -}}
  35. {{- end -}}
  36. {{- end -}}
  37. {{/* ixVolume */}}
  38. {{- if eq $storage.type "ixVolume" -}}
  39. {{- if not $storage.ixVolumeConfig -}}
  40. {{- fail (printf "Storage Shim - Expected non-empty [ixVolumeConfig]") -}}
  41. {{- end -}}
  42. {{- $datasetName = $storage.ixVolumeConfig.datasetName -}}
  43. {{- end -}}
  44. {{/* SMB Share */}}
  45. {{- if eq $storage.type "smb-pv-pvc" -}}
  46. {{- if not $storage.smbConfig -}}
  47. {{- fail (printf "Storage Shim - Expected non-empty [smbConfig]") -}}
  48. {{- end -}}
  49. {{- $server = $storage.smbConfig.server | quote -}}
  50. {{- $share = $storage.smbConfig.share | quote -}}
  51. {{- $domain = $storage.smbConfig.domain | quote -}}
  52. {{- $username = $storage.smbConfig.username | quote -}}
  53. {{- $password = $storage.smbConfig.password | quote -}}
  54. {{- if $storage.smbConfig.mountOptions -}}
  55. {{- $mountOpts = $storage.smbConfig.mountOptions -}}
  56. {{- end -}}
  57. {{- if $storage.smbConfig.size -}}
  58. {{- $size = (printf "%vGi" $storage.smbConfig.size) -}}
  59. {{- end -}}
  60. {{- end -}}
  61. {{/* emptyDir */}}
  62. {{- if eq $storage.type "emptyDir" -}}
  63. {{- if not $storage.emptyDirConfig -}}
  64. {{- fail (printf "Storage Shim - Expected non-empty [emptyDirConfig]") -}}
  65. {{- end -}}
  66. {{- if $storage.emptyDirConfig.medium -}}
  67. {{- $medium = $storage.emptyDirConfig.medium -}}
  68. {{- end -}}
  69. {{- if $storage.emptyDirConfig.size -}}
  70. {{- $size = (printf "%vGi" $storage.emptyDirConfig.size) -}}
  71. {{- end -}}
  72. {{- end }}
  73. type: {{ $storage.type }}
  74. size: {{ $size }}
  75. hostPath: {{ $hostPath }}
  76. datasetName: {{ $datasetName }}
  77. readOnly: {{ $readOnly }}
  78. medium: {{ $medium }}
  79. server: {{ $server }}
  80. share: {{ $share }}
  81. domain: {{ $domain }}
  82. username: {{ $username }}
  83. password: {{ $password }}
  84. {{- if eq $storage.type "smb-pv-pvc" }}
  85. mountOptions: {{ $mountOpts | toYaml | nindent 2 }}
  86. {{- end }}
  87. {{- end -}}