-
Notifications
You must be signed in to change notification settings - Fork 888
allow adding env variables via CLI #11338
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
Comments
@matifali Regarding implementation, should we limit the ability to invoke This would let us implement it in a way where the envs are ephemeral, i.e. they don't stick around if the agent is restarted (they need to be re-set by script). We also don't need any API endpoints on Optionally we can also allow manual invocation within the workspace, but I think if a user needs that, dotfiles are probably a more appropriate location. If we allow for other use-cases wrt setting envs, I'm afraid it might lead to confusion of when they apply and when they don't. For instance, does a workspace stop/start wipe the env, or persist it? Does it apply to all agents or only one? Etc. |
@mafredri Good questions.
I think we should not limit the use but can assume that they will be primarily set in
What does this mean? It's not a good UX if a user manually specifies the agent name. If I am correct,
A stop is usually stopping/destroying a VM or container so the
I agree. We should not block this use-case. |
Oh, sorry it was unclear, I was not referring to specifying the agent, instead I was suggesting we might put the command under I don't think it'd be nice UX if we had the command there, but it said "this can only be run inside the workspace", but then again, maybe that's OK.
By not blocking, are you referring to that we should allow manual |
Yes
I still prefer the What do you think @bpmct? |
After a discussion on Slack we came to the conclusion that there's no real need for this at this time. It's preferable to set environments declaratively in Terraform. Setting them in run-time introduces a race between starting processes and scripts modifying the environment as changes won't propagate to old processes. Use-cases like refreshing tokens can be by wrapping binaries that need to perform authentication. Such use-cases can be amended by #11131. If the need arises, we can re-open. |
Context
Coder now has a resource named
coder_env
that can be used to inject environment variables into the workspace.There is one use case where a module author would like to do this conditionally depending on if another binary is in the
PATH
. This could be used to install and configure vscode extensions for thecode-server
if it is already installed and inject the environment variables for automatic login.One example is the JFrog VS Code extension that supports auto-login if we set the following environment variables.
Suggestion
Provide a CLI command
coder env
that can be used to set/unset environment variables within acoder_script
.This can then be used to set the environment variables conditionally.
The syntax is based on the same pattern as
gh variable set
.cc: @bpmct @mafredri @kylecarbs
Tip
As a bonus, this can also allow modifying
$PATH
, e.g.,coder env set PATH --body "/tmp/code-server/bin/coder-server:$PATH"
The text was updated successfully, but these errors were encountered: