Skip to content

Validate container tags

Guilherme Gallo requested to merge gallo/ci-templates:tag-validation into master

This MR adds a validation layer for container tagging to dump better message errors to the user when the tag is bad-formatted. After making the core commit, I encountered some problems during ci-fairy image recreation: the pip install on the system environment. So, this MR also fixes that.

Docker has some rules on tag formatting, as per https://docs.docker.com/engine/reference/commandline/image_tag/#description

So, let's create a function to help us validate it, and give a meaningful message to the user if the validation fails.

The current workflow requires more work to grasp why the tagging fails.

For example, having a very long tag (> 128 characters) would print the following error invalid reference format, which is not clear, as one can see at the end of this GitLab trace here

Error message:

+ buildah commit --format docker x86_64_test-base-working-container registry.freedesktop.org/gallo/linux/debian/x86_64_test-gl:2022-01-24-mesa-uprev--2022-01-24-mesa-uprev--67f2c46b--v6.6.12-for-mesa-ci-5a92d0709d0b--d5aa3941aa03c2f716595116354fb81eb8012acb
cannot parse input: "registry.freedesktop.org/gallo/linux/debian/x86_64_test-gl:2022-01-24-mesa-uprev--2022-01-24-mesa-uprev--67f2c46b--v6.6.12-for-mesa-ci-5a92d0709d0b--d5aa3941aa03c2f716595116354fb81eb8012acb": invalid reference format

Example of a better error message, using cbuild from this MR:

https://gitlab.freedesktop.org/gallo/linux/-/jobs/54229417

Error message:

Tag 2022-01-24-mesa-uprev--2022-01-24-mesa-uprev--67f2c46b--v6.6.12-for-mesa-ci-5a92d0709d0b--d5aa3941aa03c2f716595116354fb81eb8012acb exceeds the limit of 128 characters
Edited by Guilherme Gallo

Merge request reports