]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
script/build-with-container: support custom tag suffixes
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 14 Feb 2025 16:44:35 +0000 (11:44 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 28 Feb 2025 20:16:35 +0000 (15:16 -0500)
Previously, one could use the `--tag` option to completely override the
container tag generated by the script. However, there are cases where
one may want to add information to the tag rather than override it.
Allow the tag value to start with a plus (+) character that indicates
that the remainder of the string is to be suffixed to the generated tag.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/script/build-with-container.py

index d7ec7c0ad1254f6af2520ebe4284124ce2b49cd7..32f4d37088f0bff58a3663e4b2b8414a9ab03ce3 100755 (executable)
@@ -284,7 +284,10 @@ class Context:
         return f"{base}:{self.target_tag()}"
 
     def target_tag(self):
-        if self.cli.tag:
+        suffix = ""
+        if self.cli.tag and self.cli.tag.startswith("+"):
+            suffix = f".{self.cli.tag[1:]}"
+        elif self.cli.tag:
             return self.cli.tag
         branch = self.cli.current_branch
         if not branch:
@@ -292,7 +295,7 @@ class Context:
                 branch = _git_current_branch(self).replace("/", "-")
             except subprocess.CalledProcessError:
                 branch = "UNKNOWN"
-        return f"{branch}.{self.cli.distro}"
+        return f"{branch}.{self.cli.distro}{suffix}"
 
     def base_branch(self):
         # because git truly is the *stupid* content tracker there's not a
@@ -301,7 +304,7 @@ class Context:
         # container bootstrap we default to `main` even when that's not true.
         # One can explicltly set the base branch on the command line to invoke
         # customizations (that don't yet exist) or invalidate image caching.
-        return self.cli.base_branch or 'main'
+        return self.cli.base_branch or "main"
 
     @property
     def from_image(self):
@@ -678,7 +681,8 @@ def parse_cli(build_step_names):
     parser.add_argument(
         "--tag",
         "-t",
-        help="Specify a container tag",
+        help="Specify a container tag. Append to the auto generated tag"
+        " by prefixing the supplied value with the plus (+) character",
     )
     parser.add_argument(
         "--base-branch",