_termination.tpl 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. {{/* Returns termination */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.container.termination" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the container.
  6. */}}
  7. {{- define "ix.v1.common.lib.container.termination" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $termination := (dict "messagePath" "" "messagePolicy" "") -}}
  11. {{- with $objectData.termination -}}
  12. {{- with .messagePath -}}
  13. {{- $_ := set $termination "messagePath" (tpl . $rootCtx) -}}
  14. {{- end -}}
  15. {{- with .messagePolicy -}}
  16. {{- $policy := (tpl . $rootCtx) -}}
  17. {{- $policies := (list "File" "FallbackToLogsOnError") -}}
  18. {{- if not (mustHas $policy $policies) -}}
  19. {{- fail (printf "Container - Expected <termination.messagePolicy> to be one of [%s], but got [%s]" (join ", " $policies) $policy) -}}
  20. {{- end -}}
  21. {{- $_ := set $termination "messagePolicy" $policy -}}
  22. {{- end -}}
  23. {{- end -}}
  24. {{- $termination | toJson -}}
  25. {{- end -}}