how to use jsonpath
in when
condition
#7413
-
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: my-pipeline
spec:
entrypoint: main
arguments:
parameters:
- name: myjson
value: '{"key1": 100}'
templates:
- name: main
dag:
tasks:
- name: dummy
when: "1 < {{jsonpath(workflow.parameters.myjson), '$.key1')}}"
inline:
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["echo {{workflow.parameters.myjson}}"] I was trying to access the json value in when: "1 < {{jsonpath(workflow.parameters.myjson), '$.key1')}}" but got this error:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
I believe you are missing when: "1 < {{jsonpath(workflow.parameters.myjson), '$.key1')}}" should turn to when: "1 < {{=jsonpath(workflow.parameters.myjson), '$.key1')}}" |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
-
|
Beta Was this translation helpful? Give feedback.
-
Just abuse a bug to make it work. apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: my-pipeline
spec:
entrypoint: main
arguments:
parameters:
- name: myjson
value: '{"key1": 100}'
templates:
- name: main
dag:
tasks:
- name: dummy
when: "1 < {{=jsonpath(workflow.parameters.myjson, '$.key1')}}"
inline:
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["echo {{workflow.parameters.myjson}}"]
The part of Argo Workflows that shouts at you for using expressions in It's a bit like drinking your Coca-Cola before going through airport security. You're moving the same stuff, but now it's allowed. (I can't think of a good metaphor for the expression failing to execute... you try to drink the Coke, but the lid is too tight? idk. Anyway, you gotta drink the Coke, or you're not getting through security.) |
Beta Was this translation helpful? Give feedback.
Just abuse a bug to make it work.