Conditional Execution
Conditional execution of steps and tasks is available through the basic when clause, along with
more complex expressions and Task functions.
Basic when Clauses
Argo uses govaluate in its when expressions. Hera is compatible with these
when expression if you write them in literal strings. However, without prior Argo knowledge, you may not know the
chain of keys to access steps and their parameters. Hera offers some convenience functions you can use to create when
expressions using f-strings.
The following compares an output parameter with a value:
This compares the special result output with a value:
Complex when Clauses
If you want to use more complex when clauses than simple comparisons, involving Argo expression functions such as
filter or map or even sprig functions, you should check out Hera’s
expr module documentation.
Improved Task Conditionals
When using DAGs, there are many convenience functions we can use:
on_successon_failureon_erroron_other_resultwhen_any_succeededwhen_all_failedon_workflow_status
These functions (except on_workflow_status) are essentially aliases to Task’s next function, with the on
parameter populated with the corrected TaskResult, so they can be used to set stricter dependencies than with the
rshift (>>) operator.