_cronjobValidation.tpl 1.1 KB

1234567891011121314151617181920212223242526272829
  1. {{/* CronJob Validation */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.workload.cronjobValidation" (dict "objectData" $objectData) -}}
  4. rootCtx: The root context of the chart.
  5. objectData:
  6. completionMode: The completionMode of the object.
  7. completions: The completions of the object.
  8. parallelism: The parallelism of the object.
  9. */}}
  10. {{- define "ix.v1.common.lib.workload.cronjobValidation" -}}
  11. {{- $objectData := .objectData -}}
  12. {{- if $objectData.concurrencyPolicy -}}
  13. {{- $concurrencyPolicy := $objectData.concurrencyPolicy -}}
  14. {{- $policies := (list "Allow" "Forbid" "Replace") -}}
  15. {{- if not (mustHas $concurrencyPolicy $policies) -}}
  16. {{- fail (printf "CronJob - Expected <concurrencyPolicy> to be one of [%s], but got [%v]" (join ", " $policies) $concurrencyPolicy) -}}
  17. {{- end -}}
  18. {{- end -}}
  19. {{- if not $objectData.schedule -}}
  20. {{- fail "CronJob - Expected non-empty <schedule>" -}}
  21. {{- end -}}
  22. {{/* CronJob contains a job inside, so we validate job values too */}}
  23. {{- include "ix.v1.common.lib.workload.jobValidation" (dict "objectData" $objectData) -}}
  24. {{- end -}}