-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Add extra_env_vars
field to experimental_shell_command
target.
#15742
Add extra_env_vars
field to experimental_shell_command
target.
#15742
Conversation
[ci skip-rust] [ci skip-build-wheels]
@@ -324,6 +335,7 @@ class ShellCommandTarget(Target): | |||
ShellCommandSourcesField, | |||
ShellCommandTimeoutField, | |||
ShellCommandToolsField, | |||
ShellCommandExtraEnvVarsField, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this to the end but looks like it should maybe be put in alphabetical order? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm one in favor of sorting lists alphabetically, however here I think the order affects the order the fields are presented in the documentation so that is worth considering too.
@@ -162,6 +164,9 @@ async def prepare_shell_command_process( | |||
rationale=f"execute `{shell_command.alias}` {shell_command.address}", | |||
) | |||
|
|||
extra_env = await Get(Environment, EnvironmentRequest(extra_env_vars)) | |||
command_env.update(extra_env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried setting command_env = await Get(Environment, EnvironmentRequest(extra_env_vars))
from the start, but Environment
is frozen so it doesn't allow the follow-up additions needed to set the tools path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you.
help = softwrap( | ||
""" | ||
Additional environment variables to include in the shell process. | ||
Entries are strings in the form `ENV_VAR=value` to use explicitly; or just | ||
`ENV_VAR` to copy the value of a variable in Pants's own environment. | ||
""" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably worth extracting this help string to a templating function, maybe in src/python/pants/engine/environment.py
? It's duplicated in at least src/python/pants/backend/python/target_types.py
and src/python/pants/core/goals/test.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... or defining a Field
superclass that provides it? Maybe overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be done as a follow up as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet 😄
Closes #15728
[ci skip-rust]
[ci skip-build-wheels]