Skip to content
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

Support glob patterns in subprocess-environment env_vars #20291

Open
olivercoleman-switchdin opened this issue Dec 15, 2023 · 4 comments · May be fixed by #21781
Open

Support glob patterns in subprocess-environment env_vars #20291

olivercoleman-switchdin opened this issue Dec 15, 2023 · 4 comments · May be fixed by #21781

Comments

@olivercoleman-switchdin
Copy link
Contributor

It was bad enough that I had to spend half a day figuring out why environment variables didn't seem to be working in tests executed via pants as one might reasonably expect 🤪 (when digging around just now I noticed there's been some suggestions that this should be the default behaviour, so consider that a secondary request if you will!)

I eventually found the subprocess-environment.env_vars option and added the necessary env vars in there.

This feature request is for adding support for specifying env var names with glob patterns. This would be especially handy for:

  • groups of env vars like AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, ..., with a single AWS_* entry, or
  • Including all env vars with a single * entry (at least getting closer to the expected behaviour of including all env vars, see whining above ;))
@olivercoleman-switchdin
Copy link
Contributor Author

Guessing this should also be applied to the extra_env_vars option, if it were to be applied at all.

@huonw
Copy link
Contributor

huonw commented Jan 13, 2024

Here's a fun edge case: I think * is technically valid as an env var name, e.g. env 'ABC_*_GHI=1' env includes an ABC_*_GHI=1 line. Thus, supporting glowing here would mean one could not pass through only ABC_*_GHI, literally (it'd also allow passing through ABC_DEF_GHI etc.).

This is probably acceptable, though.

@d-m
Copy link

d-m commented Oct 25, 2024

Agree this would also be helpful for passing in Terraform environment variables all at once (TF_VAR_*).

@cognifloyd
Copy link
Member

Some kind of prefix matching would be really helpful in the StackStorm repo where I've been adding test-specific-config env vars. So far I have 23 vars listed in pants.toml [test].extra_env_vars.
https://github.com/StackStorm/st2/blob/e97b7d2c6efa97a4507e0a2b7aea5ba6da76ac3d/pants.toml#L238-L267

All but 2 of them have the same prefix ST2TESTS_, so if I could glob/regex or do a prefix match on vars that would vastly simplify the config.

@lilatomic lilatomic linked a pull request Dec 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants