Hi folks. I am looking to write a plugin that can ...
# plugins
a
Hi folks. I am looking to write a plugin that can read a version file from the pex_binary and use that to generate the tags on a docker image. Does anyone have any pointers on what is a good way of accomplishing this?
c
The example plugin actually shows how to write a plugin that does custom tags: https://www.pantsbuild.org/docs/tagging-docker-images#providing-additional-image-tags-with-a-plugin that's a good start
I've had a play myself, wanting to implement this: https://pantsbuild.slack.com/archives/C046T6T9U/p1671148361756449 But I'm not a very strong python developer, and I'm not 100% clear on how to connect the setuptools_scm/vcs_version to the custom image tags rule.
The way I'm doing what you are describing today is by doing version tagging external to pants via autotag, exporting that value to a env var, and including that env var for the build_args: https://www.pantsbuild.org/docs/tagging-docker-images#using-env-vars-to-include-dynamic-data-in-tags
c
There’s also an upcoming tutorial series by @fresh-cat-90827 (available on Github for the time being) starting off with showing how to write a plugin that reads a version from a file. https://github.com/pantsbuild/pants/tree/main/docs/markdown/Tutorials
1
a
@curved-television-6568 thanks for that link. It was incredibly helpful.
❤️ 1
c
Happy it was useful. Credits should all be directed at @fresh-cat-90827 for writing it up 😄
❤️ 1