_validation.tpl 903 B

12345678910111213141516171819202122
  1. {{/* Persistence Validation */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.persistence.validation" (dict "objectData" $objectData) -}}
  4. objectData:
  5. rootCtx: The root context of the chart.
  6. objectData: The persistence object.
  7. */}}
  8. {{- define "ix.v1.common.lib.persistence.validation" -}}
  9. {{- $rootCtx := .rootCtx -}}
  10. {{- $objectData := .objectData -}}
  11. {{- $types := (list "emptyDir" "hostPath" "ixVolume" "secret" "configmap" "device") -}}
  12. {{- if not (mustHas $objectData.type $types) -}}
  13. {{- fail (printf "Persistence - Expected <type> to be one of [%s], but got [%s]" (join ", " $types) $objectData.type) -}}
  14. {{- end -}}
  15. {{- if and $objectData.targetSelector (not (kindIs "map" $objectData.targetSelector)) -}}
  16. {{- fail (printf "Persistence - Expected <targetSelector> to be [dict], but got [%s]" (kindOf $objectData.targetSelector)) -}}
  17. {{- end -}}
  18. {{- end -}}