https://pantsbuild.org/ logo
f

famous-river-94971

01/12/2023, 6:31 PM
Is there a way I can write a custom "bootstrap" script for
pants
? I use CodeArtifact for a private PyPi repository, so I need
CODEARTIFACT_AUTH_TOKEN
to be set in the environment. It'd be pretty cool if I could somehow hook into the bootstrap process to: • check if the
CODEARTIFACT_AUTH_TOKEN
environment variable is set. ◦ if so, continue ◦ if not, set it ▪︎ upon failure, throw an error message telling the dev what to do Is this possible? Thanks!
f

fast-nail-55400

01/12/2023, 6:32 PM
The
,/pants
script can always be customized for your reposiory.
f

famous-river-94971

01/12/2023, 6:33 PM
Oh, interesting. I was thinking about this as a "vendored" script (e.g., don't touch it)
l

loud-laptop-17949

01/12/2023, 6:34 PM
you can also use
.pants.bootstrap
👀 1
which gets sourced by the default
./pants
script
f

fast-nail-55400

01/12/2023, 6:34 PM
I didn't even know that. learned something new! 🙂
l

loud-laptop-17949

01/12/2023, 6:35 PM
i can't find docs for it right now
maybe its a 2.15 thing?
f

fast-nail-55400

01/12/2023, 6:42 PM
The
./pants
script lives in its own repo: https://github.com/pantsbuild/setup/blob/gh-pages/pants
so maybe docs are in that repo?
although we then link people back to https://www.pantsbuild.org/docs/installation so maybe time to add some docs to the docs site
b

bitter-ability-32190

01/12/2023, 6:51 PM
FWIW when we switch to `scie-pants`that may or may not get ported. I think the current assumption is it is just for env vars (similar to .env)
e

enough-analyst-54434

01/12/2023, 10:51 PM
It's already ported
f

famous-river-94971

01/13/2023, 5:56 PM
This is working great for me - thanks for the pointer!
Btw, the default/recommended
.gitignore
excludes this file: https://www.pantsbuild.org/docs/initial-configuration (see step 4 which recommends):
Copy code
# Pants workspace files
/.pants.*
/dist/
/.pids
I updated it locally to use this:
Copy code
# Pants workspace files
/.pants.*
!.pants.bootstrap
/dist/
/.pids
Should the docs be updated?
l

loud-laptop-17949

01/13/2023, 5:58 PM
It depends - we use it in such a way that we want it checked in (contains no secrets).
f

famous-river-94971

01/13/2023, 5:58 PM
Ah, sure. Makes sense that sometimes you wouldn't want it tracked.
b

bitter-ability-32190

01/13/2023, 5:59 PM
The glob predates that file. Might need updating
f

famous-river-94971

01/13/2023, 6:00 PM
I guess it depends on which one is less like a "foot gun". Track by default, opting out if you have secrets in there, or vice versa.
e

enough-analyst-54434

01/13/2023, 6:16 PM
Leaking secrets is always a bigger footgun than ~anything.
f

famous-river-94971

01/13/2023, 6:16 PM
Sure. if the intention is that the bootstrap file will usually contain secrets, then it's probably safest to exclude it. In my case, it does not contain secrets.
e

enough-analyst-54434

01/13/2023, 6:17 PM
And there's a difference between footguns and handholding. I trust devs to not really need handholding.
f

famous-river-94971

01/13/2023, 6:18 PM
Is the handholding you're referencing "knowing how to use .gitignore"?
In any case, I don't feel strongly either way. I just wanted to bring it up since I knew it's a new file and I ran into it ¯\_(ツ)_/¯
e

enough-analyst-54434

01/13/2023, 6:21 PM
Yeah, I trust devs to know how to use .gitignore.
👌 1
5 Views