Argo workflows expression tester
Argo has a complex expression language to modify parameters in its workflows
It is difficult for a go novice to figure out how these work.
This CLI provides a way to test the expressions before submitting the workflow to argo.
Installation
go install github.com/blacha/argo-expr@latest
Usage
simple math
argo-expr "{{=asInt(input.parameters.name) + 1}}" --value input.parameters.name="1" --json
output:
{
"input": "{{=asInt(input.parameters.name) + 1}}",
"result": "2",
"values": {
"input.parameters.name": "1"
}
}
Create a sha256sum raw string
argo-expr '{{=sprig.sha256sum("hello world")}}' --json
output:
{
"input": "{{=sprig.sha256sum(\"hello world\")}}",
"result": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
"values": {}
}
argo-expr '{{=sprig.sha256sum(input.value)}}' --value input.value="hello world" --json
output
{
"input": "{{=sprig.sha256sum(\"hello world\")}}",
"result": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
"values": {}
}
load from file
input.json
{
"input": "hello world 1+1:{{=1+1}} i:{{=i}}",
"values": {
"i": "4"
}
}
argo-expr --from-file ./input.json
output
hello world 1+1:2 i:4
Values can be overridden
argo-expr --from-file ./input.json --value i=1
output
hello world 1+1:2 i:2
argo-expr --from-file ./input.json "i:{{=asInt(i)+3}}"
output
i:7