-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sprig functions do not work in a pipeline #13759
Comments
I patched the workflow controller to always show error messages from expr and then ran the attached workflow again.
If a function is assigned to a variable to avoid
|
I also found that usage of sprig functions is confusing in Argo Workflows. https://argo-workflows.readthedocs.io/en/stable/variables/
but examples in the Sprig document basically do not work in Argo Workflows: 1: Parentheses are required to call functions
expr error message:
2: The pipe operator (
expr error message:
The main reason is that Sprig document uses the template engine in the golang standard library while Argo Workflows uses expr. apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: test-workflow-
spec:
ttlStrategy:
secondsAfterCompletion: 1
entrypoint: main
templates:
- name: main
script:
image: busybox:1.37.0
command:
- ash
source: |-
echo '
If a function is assigned to a variable to avoid `.` in a pipeline, the evaluation succeeds:
{{=
let sprig_upper = sprig.upper;
sprig.trim(" abc ") | sprig_upper()
}} # == ABC
sprig document example: http://masterminds.github.io/sprig/strings.html#trim
{{=sprig.trim " hello "}} # fail
Correct syntax in Argo Workflows
{{=sprig.trim(" hello ")}} # == hello
In the sprig document, a left-hand side value is passed to the last argument of the function by the pipe operator
sprig document example: http://masterminds.github.io/sprig/crypto.html#decryptaes
{{=
let decryptAES = sprig.decryptAES;
"30tEfhuJSVRhpG97XCuWgz2okj7L8vQ1s6V9zVUPeDQ=" | decryptAES("secretkey")
}} # fail in Argo Workflows
In expr, a left-hand side value is passed to the first argument of the function by the pipe operator
Correct syntax:
{{=
let decryptAES = sprig.decryptAES;
"secretkey" | decryptAES("30tEfhuJSVRhpG97XCuWgz2okj7L8vQ1s6V9zVUPeDQ=")
}} # == plaintext
"
' |
are you willing to submit a PR for this else can you share the code change for this? |
Signed-off-by: boiledfroginthewell <[email protected]>
I'm not planning to submit a PR because the change is just a quick fix. It shows errors when it shouldn't, and I'm not sure if workflow controller logs are the appropriate place to show them. Here is the code change I used: https://github.com/argoproj/argo-workflows/pull/13774/files |
Pre-requisites
:latest
image tag (i.e.quay.io/argoproj/workflow-controller:latest
) and can confirm the issue still exists on:latest
. If not, I have explained why, in detail, in my description below.What happened? What did you expect to happen?
Expressions are not evaluated when sprig functions are used after a pipe (
|
) operator.Outputs of the attached workflow:
Version(s)
v3.4.17, v3.5.11, latest git main branch (0dfecd6)
Paste a minimal workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.
Logs from the workflow controller
Logs from in your workflow's wait container
The text was updated successfully, but these errors were encountered: