37 lines
1.1 KiB
HCL
37 lines
1.1 KiB
HCL
[[- /*
|
|
# vim: syntax=hcl
|
|
# Note: for compatibility, we take volumes either from .volumes (when passing the whole context to the template)
|
|
# or from . (when only .volumes is passed as context)
|
|
*/ -]]
|
|
[[- $volumes := dict ]]
|
|
[[- if and (has . "volumes") (isKind "map" .volumes) ]]
|
|
[[- $volumes = .volumes ]]
|
|
[[- else ]]
|
|
[[- $volumes = . ]]
|
|
[[- end ]]
|
|
[[- range $volname, $volume := $volumes ]]
|
|
|
|
[[- $type := "" ]]
|
|
[[- if has $volume "type" ]]
|
|
[[- $type = $volume.type ]]
|
|
[[- else ]]
|
|
[[- $type = "csi" ]]
|
|
[[- end ]]
|
|
|
|
volume "[[ $volname ]]" {
|
|
source = "[[ if has $volume "source" ]][[ $volume.source ]][[ else ]][[ $volname ]][[ end ]]"
|
|
type = "[[ $type ]]"
|
|
[[- if has $volume "read_only" ]]
|
|
read_only = [[ if $volume.read_only ]]true[[ else ]]false[[ end ]]
|
|
[[- end ]]
|
|
[[- if ne $type "host" ]]
|
|
access_mode = "[[ if has $volume "access_mode" ]][[ $volume.access_mode ]][[ else ]]single-node-writer[[ end ]]"
|
|
attachment_mode = "file-system"
|
|
[[- end ]]
|
|
[[- if and (has $volume "per_alloc") ($volume.per_alloc) ]]
|
|
per_alloc = true
|
|
[[- end ]]
|
|
}
|
|
|
|
[[- end ]]
|