common/templates/volumes

37 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-01-17 16:00:49 +01:00
[[- /*
# 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)
2024-01-17 16:00:49 +01:00
*/ -]]
2024-01-17 15:57:07 +01:00
[[- $volumes := dict ]]
[[- if and (has . "volumes") (isKind "map" .volumes) ]]
[[- $volumes = .volumes ]]
[[- else ]]
2024-01-17 16:12:55 +01:00
[[- $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 ]]
2023-12-13 23:09:49 +01:00
[[- end ]]
[[- if ne $type "host" ]]
access_mode = "[[ if has $volume "access_mode" ]][[ $volume.access_mode ]][[ else ]]single-node-writer[[ end ]]"
2023-12-13 23:09:49 +01:00
attachment_mode = "file-system"
2024-01-16 15:48:42 +01:00
[[- end ]]
[[- if and (has $volume "per_alloc") ($volume.per_alloc) ]]
2024-01-16 15:48:42 +01:00
per_alloc = true
2023-12-13 23:09:49 +01:00
[[- end ]]
}
[[- end ]]