-
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
Error when trying to pass Env Vars as a parameter to a template, cannot unmarshal object into Go struct #8827
Comments
@RoryDoherty Try this script:
image: ubuntu:18.04
command:
- bash
workingDir: /src
env:
- name: a
value: '{{inputs.parameters.vars}}'
source: |
echo $a |
@sandeepitachi
However I'm not trying to pass that as a string, I want to be able to set the env vars for a template within the dag task. |
I can work around this for now using the following: apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: demo-
spec:
entrypoint: demo
templates:
- name: demo
dag:
tasks:
- name: env-var-test
template: run-test
arguments:
parameters:
- name: vars
value: |
export Foo="bar"
export Bar="Foo"
- name: run-test
inputs:
parameters:
- name: vars
script:
image: ubuntu:18.04
imagePullPolicy: Always
command: [bash]
workingDir: "/src"
env:
- name: vars
value: '{{inputs.parameters.vars}}'
source: |
echo $vars > /tmp/vars
source /tmp/vars
env But it would definitely be good if we could set environment variables from the task and not just in the template |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as duplicate.
This comment was marked as duplicate.
@RoryDoherty This is by design this is not a bug. Script Template is using |
Thanks @sarabala1979 , I had seen a similar snippet in a slack thread as a working example in an earlier release which is why I opened it as a bug! |
This comment was marked as spam.
This comment was marked as spam.
I don’t believe it is possible to change this behavior The templating merging works by marshaling the string into a struct. It cannot cater for arbitrary string due to whitespacing. Even if you managed to get it to work, any small change to white space would break it. @RoryDoherty suggestion is looks like a good work-around. |
Checklist
Summary
What happened/what you expected to happen?
Tried to pass a parameter as a json/list of env vars but get the following error when submitting the workflow:
I have tried various assortments of quotes, yaml continuation using | and >
According to this thread on slack it did work at some stage so this may be a regression:
https://cloud-native.slack.com/archives/C01QW9QSSSK/p1628785975367900
What version are you running?
v3.3.5
Diagnostics
Paste the smallest workflow that reproduces the bug. We must be able to run the workflow.
Logs from the workflow controller:
There were no logs in the workflow controller when I submitted the workflow via the UI
Is there a trace logs setting I can enable?
Message from the maintainers:
Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.
The text was updated successfully, but these errors were encountered: