https://pantsbuild.org/ logo
b

brash-baker-91190

05/19/2022, 10:34 PM
Is there a way to have Pants only lint Docker images, but not build? That is, if I run
./pants package ::
, is there a way to not have it try to build the images?
f

fast-nail-55400

05/19/2022, 10:35 PM
to run hadolint?
if that, then
./pants lint ::
b

brash-baker-91190

05/19/2022, 10:36 PM
Right... that part is fine, I just don't want Pants to ever try to build these images.
f

fast-nail-55400

05/19/2022, 10:36 PM
if there is some other checks/linting being done during the image build, then that probably would have to be pulled out into a rule that could run under the lint or check goals
there’s a
skip_push
field
you probably want something like
skip_package
or
no_default_package
which would need to be implemented, but is a straight-easy contribution to make for a suitably motivated contributor
(although you can add a tag and then exclude targets with that tag)
My thought is maybe targets could be marked such that they did not match patterns like
::
but required specifying their exact address to process them.
so
./pants package path/to/target:some_docker_image
would build it but
./pants package ::
would skip it
b

brash-baker-91190

05/19/2022, 11:12 PM
Gotcha, thanks 👍
f

fast-nail-55400

05/19/2022, 11:34 PM
to be clear, I don’t plan on implementing it. feel free to open an issue with this idea if you’d like to see it.
h

happy-kitchen-89482

05/20/2022, 3:58 PM
Interesting use case. In python we model this by having the lintable thing be
python_sources
, and then a separate packageable target such as
pex_binary
or
python_distribution
points to the python_sources it consumes.
But that's not how we modeled the targets for Docker
We should probably be more uniform about this sort of thing