https://pantsbuild.org/ logo
#general
Title
# general
w

worried-salesclerk-37834

11/02/2021, 2:54 PM
When I set "PANTS_CONFIG_FILE", that will always be additive to pants.toml, right? Just making sure I'm reading the docs right before I go push someone else down a rabbit hole 😁
h

hundreds-father-404

11/02/2021, 3:05 PM
Depends how you set it. If it's
PANTS_CONFIG_FILE=pants.custom.toml
, that uses the "implicit add" syntax for list options, so yes is additive Otherwise, if you use list syntax, you could override it: https://www.pantsbuild.org/docs/options#list-values
f

fresh-cat-90827

11/02/2021, 3:49 PM
I use it as
PANTS_CONFIG_FILES=pants.ci.toml
and confirm it’s additive. https://www.pantsbuild.org/docs/using-pants-in-ci#configuring-pants-for-ci-pantscitoml-optional
👍 2
w

worried-salesclerk-37834

11/02/2021, 4:09 PM
What I'm running into are problems handling docker images for different environments (pushing to different registries for prod vs nonprod). Do you have a recommended way to handle pushing different tags or different registries for different environments @curved-television-6568?
👀 1
Specifically, I'd like to handle the case of every developer pushing their own namespaced images.
c

curved-television-6568

11/02/2021, 4:20 PM
Just to see if I got this right, @worried-salesclerk-37834 are you saying that every developer has a dedicated registry?
And also, are they pushing the same targets, but to their own registries, or is it different sets of targets?
w

worried-salesclerk-37834

11/02/2021, 4:22 PM
Dedicated repositories within a registry right now (
us-east1.pkg.dev/$(whoami)-repo-name/image-name
), but open to other solutions.
Sorry, missed your second question. We're in the process of migrating from a shell script to having pants manage it. Ideally, one target per image regardless of environment, but happy with anything that's simple enough to manage.
Hey @curved-television-6568, just wanted to check in on this. Any pointers, or would it be simplest to continue with a script for now?
c

curved-television-6568

11/03/2021, 1:04 PM
Apologies, this fell between the cracks. Will take a quick look, see if I can spot anything 🙂
Right now, there’s support for formatting the repository based on the target name, directory and parent directory only. In your case it would make sense to also be able to substitute for an environment variable.
So rather than
Copy code
docker_image(repository="{directory}/{name}", ...)
You would want to write:
Copy code
# not supported..
docker_image(repository="{env.USER}-repo-name/{name}")
But using a macro here, could turn a
custom_docker_image(…)
into a
docker_image(repository="custom-value", …)
… and have the macro look up the value you want to use. Not entirely sure what the
env
will look like for macros, though.
Oh, right, a macro may not work, as I guess you can’t import stuff in macros, so no env access there. Would need to be a plugin then.
There is another “hackish” way that could potentially work. And that is if you’re able to export a variable per user..
export PANTS_DOCKER_DEFAULT_REPOSITORY="$(whoami)-repo-name/{name}"
then that would set the repo per user invoking `./pants`…
And in pants.toml (or where applicable):
Copy code
[docker.registries.us-east]
address = "us-east1.pkg.dev"
default = true
w

worried-salesclerk-37834

11/03/2021, 2:52 PM
Lots of great info, thanks!
👍 1