I see that it's possible to specify multiple regis...
# general
h
I see that it's possible to specify multiple registries for a
docker_image
target. Is it possible to restrict which images get published when we call
pants publish
. I went through the docs quickly and didn't see any mention of controlling that behavior.
1
Use case is that we'll have an official registry always available and sometimes a local registry and I'd like to control which one I publish images to based on use case.
I see some mentions of
skip_push
here but I think I'm looking for something more like
only_push
e
The docs you reference speak of configuring registries. Is it viable to use a separate pants.toml for this and activate it when needed? The pants.ci.toml trick many folks use for other reasons in other words, but applied here.
You can have 18 pants config files and activate 3, for example. Or next time just use the default. Or next time activate 2, etc...
h
Yeah, I could see how I could achieve that. I'll play around with it.
Seems like I can't just override
skip_push
in the other toml. I have to duplicate the registry definition. Might just be using toml wrong, though.
e
I'm not sure skip push would be the right tool. The idea would be always push to all. Control pushes by controlling what all means via pants.X.toml activation.
That only works if all images can be pushed to the same registry(ies) in a given context. If you have a special flower that must never be pushed to Y or a different special flower that must always be pushed to X and Y; then this doesn't work as a hack-a-round.
h
Hmm, true. I could just change the definition of my registry instead of introducing a new registry that I nominally don't push to
Regardless, I still kind of expected my toml to get cleanly merged over
pants.toml
. Instead, I got a cryptic error saying
Copy code
12:43:04.28 [ERROR] 1 Exception encountered:

Engine traceback:
  in `publish` goal

KeyError: 'address'
e
For that I leave you to Pants experts. SOunds like a typo on your part or a bug on Pants part.
c
use
pants docker --help
to see the end result
the config is not deep merged, you can use
Copy code
[docker.registries.add]
alias = {address = "some.registry.address"}
but that’s rather clunky, and you can’t still merge the registry entry itself with what’s in the main toml config
that said, as John suggests, I think it’s easier to work with the registry config as whole units, rather than patching them.
h
It was because I omitted
address
in my secondary config
👍 1
c
ah, that could’ve been handled better.. 😉
h
But yeah, I'll do that. Has the side benefit of not having to go update all
docker_image
targets to say they could actually have two registries
I really need to start submitting pull requests
💯 1
This would be a good one
e
This is a generic technique to keep in mind that has ~0 to do with docker.
h
I just get hung up on little details like how to properly set up a development environment and do all the things and then lose steam
c
you don’t need to change the image targets tho, if you set
default = true
on multiple registries, they’ll all be used by default..
(iirc.. been a while now..)