dagu
dagu copied to clipboard
Allow complex `precondition` conditions
Brief overview
We aim to support more complex conditions in the preconditions
field.
Proposed solution: Inline script
We suggest allowing the use of JavaScript in the condition field.
Javascript
preconditions:
- condition: "$EXIT_CODE == 1 || $EXIT_CODE == 2"
expected: true
Alternative Approaches
Option 1: Functional Programming
preconditions:
- condition: "(or (eq $EXIT_CODE 1) (eq $EXIT_CODE 2))"
expected: true
Option 2: Logic Programming
preconditions:
- condition: "member($EXIT_CODE, [1, 2])"
expected: true
Alternative solution: operator
field
preconditions:
- condition: "$EXIT_CODE"
operator: "ne"
expected: "2"
When operator field is not provided, it will be handled as "eq". Valid values are as follows:
-
!=
orne
-
==
oreq
-
>=
orge
-
>
orgt
-
<=
orle
-
<
orlt
-
OR
orAND
-
conditions
Complex example that matches only when EXIT_CODE is neither 1
or 2
:
preconditions:
operator: "AND"
conditions:
- condition: "$EXIT_CODE"
operator: "ne"
expected: "1"
- condition: "$EXIT_CODE"
operator: "ne"
expected: "2"