On 11/10/2026 10:54 pm, Guillaume Tucker wrote:
Add a --registry / -R command line argument to the container tool to
specify an altnerative image registry and support it in the TOML
configuration file accordingly.

This uses a mechanism based on regular expressions to parse the
container registry and image names and construct the final one based
on a set of priority rules.  A registry can be included directly in an
image name; an empty string means a local image.  It can then be
overridden by explicitly specifying a registry name via the CLI option
or the TOML file, with the CLI option taking precedence as always.

Signed-off-by: Guillaume Tucker <[email protected]>
---
  scripts/container | 126 ++++++++++++++++++++++++++++++++++++++++++----
  1 file changed, 117 insertions(+), 9 deletions(-)

diff --git a/scripts/container b/scripts/container
index a3a55180d6ed..de72725656a8 100755
--- a/scripts/container
+++ b/scripts/container

[...]

[email protected]
+class FullImageName(ImageParserMixin):
+    """Parsed image name including an optional registry"""
+    image: ImageName
+    registry: RegistryName = None
+    _regex = re.compile(
+        rf'^((?P<registry>{REGISTRY_REGEX})\/)?(?P<image>{IMAGE_REGEX})?$'
+    )
+
+    @property
+    def name(self):
+        """Full name in registry/image:tag format with optional registry"""
+        return (
+            '/'.join((self.registry.registry, self.image.image))
+            if self.registry else self.image.image
+        )
+
+    @classmethod
+    def from_name(cls, name):
+        if re_match := cls._regex.match(name):
+            fields = re_match.groupdict()
+            return FullImageName(
+                registry=RegistryName.from_fields(fields),
+                image=ImageName.from_fields(fields),
+            )
+        return None
+
+

As one would expect, Sashiko has some opinions about this:

https://sashiko.dev/#/patchset/06ee7c694c3e9716bff5c9b1b8e9dc95cc0b38d3.1791751900.git.gtucker%40gtucker.io

I would say that at least half of it is slightly bogus but I'll
address them in detail in due time.  Also I've prepared some unit
tests to cover this logic and will send them as an RFC separately.

In the meantime, I'd be interested to know if anyone has some
feedback on the features themselves from a developer point of view.

Best wishes,
Guillaume


Reply via email to