In the below argo workflow specification
- I am generating a list of booleans from
generate-booleans
step. - I want to conditionally execute
step1
if the 0th element of the list is true.
I have tried many combinations of the expression in the when but I am unable to get a condition that executes the step1 if 0th element is true. Either the condition is not satisfied or there is an issue with token with a hint of add quotes around "$" or "{{".
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: sprig-boolean-condition-
spec:
entrypoint: main
serviceAccountName: default-editor
templates:
- name: main
steps:
- - name: generate-booleans
template: boolean-generator
- - name: step1
template: task-a
when: "\"{{=jsonpath(tasks.generate-booleans.outputs.parameters.boolean-list \"$[0]\")}}\" == \"true\""
- name: boolean-generator
script:
image: alpine
command: [python]
source: |
import json
with open('/tmp/output.txt', 'w') as f:
json.dump([True, False], f)
outputs:
parameters:
- name: boolean-list
valueFrom:
path: /tmp/output.txt
- name: task-a
container:
image: alpine
command: [sh, -c, "echo 'Task A executed'"]
Could you please let me know the correct syntax? ps: I have tried fromJson, sprig expressions but failed.