-
-
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
New env()
BUILD file function.
#17652
New env()
BUILD file function.
#17652
Conversation
3e3be08
to
8231bce
Compare
I think it may be good enough to only be able to use the At least I've not been able to figure out how to make it work otherwise.. ;) |
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.
Great idea!
@benjyw 🎉 your aws s3 fix seems to have helped :) |
Environment variables | ||
--------------------- | ||
|
||
BUILD files are very hermetic in nature with no support for using `import` or other I/O operations. In order to have dynamic data in BUILD files, you may inject values from the local environment using the `env()` function. It takes the variable name and optional default value as arguments. |
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.
Sorry to snipe this review after merge. Can we document whether sensitive env vars are safe to load? Why/why not?
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.
Sounds like a good idea. I don't know the answer though.. :)
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.
@stuhood ?
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 mean... it just depends where they are being used, I suppose? Technically you could use this to interpolate an env
var into a target name or something, at which point your secret would leak via ./pants list
.
So it's very use-site specific.
Joining the snipe here, can you document whether or not the env-var value is part of the cache key? In this case, in each new build (even for the same commit), the version would change and I wouldn't want it to invalidate the package. |
When packaging a target, the hash value of that target will be part of the cache key, and if any of the target's fields values change the hash value change. In other words, yes the env-var value will be part of the cache key--as will it be if injected by any other means using the Your use case is a bit tricky, as you change some input which has a noticeable effect on the output but wish it to not trigger a rebuild. For that to work, we'd need to have a way to mark values with a constant hash regardless of its underlying value in order to not invalidate previous work when changed. |
Closes #12797
Make BUILD file parsing a two pass operation, where the first pass is just walking the AST to fish out any
env(...)
calls so we can provide the requested env vars for the second pass.Example: