Skip to content

Commit 653e5f1

Browse files
hack/build-image: option to create images without unqualified tags
Allow the script to skip creating unqualified tags on images (like 'nightly' or 'latest'). Signed-off-by: John Mulligan <[email protected]>
1 parent 4e216c1 commit 653e5f1

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

hack/build-image

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,23 +592,33 @@ class BuildRequest:
592592
def __bool__(self):
593593
return bool(self.images or self.indexes)
594594

595-
def expanded(self, indexes=False, distro_qualified=True):
595+
def expanded(
596+
self, indexes=False, distro_qualified=True, unqualified=True
597+
):
596598
new_req = self.__class__(self.images, self.indexes)
597599
if indexes:
598600
new_req._build_indexes()
599-
new_req._expand_special_tags(distro_qualified=distro_qualified)
601+
new_req._expand_special_tags(
602+
distro_qualified=distro_qualified, unqualified=unqualified
603+
)
600604
return new_req
601605

602-
def _expand_special_tags(self, distro_qualified=True):
606+
def _expand_special_tags(self, distro_qualified=True, unqualified=True):
603607
if self.indexes:
604608
for image in self.indexes:
605609
# distro qualified is redundant with the default tag of an
606610
# index/manifest as well as mainly needed for backwards
607611
# compatibility something we don't want for indexes.
608-
add_special_tags(image, distro_qualified=False)
612+
add_special_tags(
613+
image, distro_qualified=False, unqualified=unqualified
614+
)
609615
else:
610616
for image in self.images:
611-
add_special_tags(image, distro_qualified=distro_qualified)
617+
add_special_tags(
618+
image,
619+
distro_qualified=distro_qualified,
620+
unqualified=unqualified,
621+
)
612622

613623
def _build_indexes(self):
614624
_indexes = {}
@@ -645,11 +655,13 @@ def generate_request(cli):
645655
)
646656
images[str(timg)] = timg
647657
return BuildRequest(images=images.values()).expanded(
648-
indexes=cli.combined, distro_qualified=cli.distro_qualified
658+
indexes=cli.combined,
659+
distro_qualified=cli.distro_qualified,
660+
unqualified=cli.unqualified,
649661
)
650662

651663

652-
def add_special_tags(img, distro_qualified=True):
664+
def add_special_tags(img, distro_qualified=True, unqualified=True):
653665
"""Certain images have special tags. Given an image, add general (non-FQIN)
654666
tags to that image.
655667
"""
@@ -659,7 +671,7 @@ def add_special_tags(img, distro_qualified=True):
659671
# the project.
660672
_host_arch = host_arch()
661673
arch_ok = img.supports_arch(_host_arch)
662-
if img.distro in [FEDORA, OPENSUSE]:
674+
if unqualified and img.distro in [FEDORA, OPENSUSE]:
663675
if arch_ok and img.pkg_source == DEFAULT:
664676
img.additional_tags.append((LATEST, QUAL_NONE))
665677
if arch_ok and img.pkg_source == NIGHTLY:
@@ -979,6 +991,14 @@ def main():
979991
" will be created."
980992
),
981993
)
994+
parser.add_argument(
995+
"--unqualified",
996+
action=argparse.BooleanOptionalAction,
997+
default=True,
998+
help=(
999+
"Specify if image tags like nightly or latest" " will be created."
1000+
),
1001+
)
9821002
parser.add_argument(
9831003
"--combined",
9841004
action=argparse.BooleanOptionalAction,

0 commit comments

Comments
 (0)