-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Proposal: Merge vars
and env
#2036
Comments
Hey @pd93, Two years ago, I opened an issue proposing something different, but that has the same objetive of reducing the confusion between vars and envs: In that proposal, instead of merging vars and envs, we'd be actually making them completely separate. The idea is that
With my proposal, no env would be automatically be recognized as a variable, in any circustance. Both proposals are valid, and I'm open to discuss both. /cc @vmaerten Any thoughts? |
This is the crux of the problem. Are vars and envs really the same thing? Or are they actually different. I've developed a "mental model" that vars are something internal, between tasks, and envs are something that comes from the calling process, and might be forwarded to a called process - typically credentials (or similar). Having envs distinguishable from vars ( Also, deciding what to "pass along" becomes important, since it may be necessary to restrict what a called task can discover from the callee task (credential leaks come to mind). |
Hey @pd93 & @andreynering, I'll start by quoting you:
Merging
|
version: '3'
tasks:
deploy:
vars:
AWS_PROFILE: 'dev'
cmds:
- aws s3 ....
- aws lambda ....
- aws cloudfront invalid ... @vmaerten It would be exactly the same as now, just using I don't personally see the need for two separate concepts. They provide mostly the same functionality, but with minor differences. This is where the confusion comes from. I have had multiple people ask me what the differences actually are. I'm not absolutely against separating them, but I'm not a fan of having to use functions to access variables and env vars as in #1065. It doesn't seem as intuitive as directly referencing one and goes against most templating systems I've used. For reference, GitHub actions does have variables and environment variables, but variables are only inputs. You cannot set them in the action config files. In the configs, you are only able to set variables using the |
One of the things I see a lot, is confusion about the differences between variables and environment variables. They essentially serve the same purpose (holding data), but they have a few differences:
TASK_VAR=foo task ...
(environment variable)task ... VAR=foo
(variable)vars
can also be set when calling another task, butenv
cannot.vars
can be of any type.env
only supports strings (though sort of works with other scalar values).vars
are output using templating syntax and anenv
is output using shell variable syntax.$FOO
(environment variable){{.FOO}}
(variable)env
keyword are not.I'm not convinced that any of these distinctions are necessary and I feel like they add an additional layer of confusion for both new users and people wanting to contribute to the project.
Therefore, I propose removing the
env
key entirely.vars
would then inherit from the system environment and be overridable in Task. If a variable is not a string, it would be output using the stringer version of its value (%v
). All of the features below would then apply tovars
:task ... VAR=foo
syntax.Before:
After:
One caveat to this proposal is that sometimes temporary variables are needed to perform operations and we don't always want to pollute the environment with these variables. To solve this, we can allow variables to be marked as internal, just like we would with tasks. This makes variables consistent with tasks and fulfills the same purpose that variables previously did.
Since most Task commands execute in a fairly specific context, this shouldn't be needed the majority of the time.
The text was updated successfully, but these errors were encountered: