mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 18:26:22 -03:00
init work for ixVols
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
{{- define "ix.v1.common.controller.volumes.hostPath.validation" -}}
|
||||
{{- if $root.Values.global.defaults.validateHostPaths -}} {{/* TODO: global or per volume flag? */}}
|
||||
{{- $incomingData := .incoming -}} {{/* TODO: change variable name... temp implementation */}}
|
||||
{{- $allowed_paths := (list "mnt" "sys" "dev" "cluster") -}}
|
||||
{{- $errorMessage := (printf "Invalid hostPath (%s). Allowed hostPaths are valid paths under a given pool. e.g. /mnt/POOL/DATASET, /mnt/POOL/DATASET/DIRECTORY" $incomingData) -}}
|
||||
{{- $hostPath := splitList "/" $incomingData -}} {{/* Split the path into a list */}}
|
||||
{{- $hostPath := (mustWithout $hostPath "") -}} {{/* Drop any list items with empty strings */}}
|
||||
{{- $pathStart := (index $hostPath 0) -}}
|
||||
{{- if not (mustHas ($pathStart $allowed_paths)) -}}
|
||||
{{- fail $errorMessage -}}
|
||||
{{- else if eq $pathStart "mnt" -}}
|
||||
{{- if lt (len $hostPath) 3 -}}
|
||||
{{- fail $errorMessage -}}
|
||||
{{- end -}}
|
||||
{{- else if eq $pathStart "cluster" -}}
|
||||
{{- if lt (len $hostPath) 2 -}}
|
||||
{{- fail $errorMessage -}}
|
||||
{{- else if eq (index $hostPath 1) "ctdb_shared_vol" -}}
|
||||
{{- fail $errorMessage -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{/* TODO: unittests */}}
|
||||
@@ -1,7 +1,18 @@
|
||||
{{- define "ix.v1.common.controller.volumes.ixVols" -}}
|
||||
{{- $index := .index -}}
|
||||
{{- $vol := .volume -}}
|
||||
{{- $root := .root }}
|
||||
{{- $root := .root -}}
|
||||
{{- if not $vol.datasetName -}}
|
||||
{{- fail (printf "Item (%s) is set as ixVolume type, but has no Dataset Name defined" $index) -}}
|
||||
{{- end -}}
|
||||
{{- if not (mustHas $vol.datasetName $root.ixVolumes) -}} {{/* Make sure the resolved datasetName is included in ixVolumes */}}
|
||||
{{- fail (printf "Dataset Name on item (%s) does not exist in ixVolumes list" $index) -}}
|
||||
{{- end }}
|
||||
- name: {{ $index }}
|
||||
|
||||
hostPath:
|
||||
path: {{ required (printf "hostPath not set on item %s" $index) $vol.hostPath }}
|
||||
{{- with $vol.hostPathType }}
|
||||
type: {{ tpl . $root }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{/* TODO: unittests */}}
|
||||
|
||||
Reference in New Issue
Block a user