Skip to content

Commit

Permalink
container_image_items attribute for OperatorManifestPushItem model (#357
Browse files Browse the repository at this point in the history
)

New attribute is the list of related container images to specific operator
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
midnightercz and pre-commit-ci[bot] authored Aug 23, 2023
1 parent cd120ea commit b05b7e8
Show file tree
Hide file tree
Showing 5 changed files with 3,028 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/pushsource/_impl/backend/koji_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def _push_items_from_container_build(self, nvr, meta):
)

# If this build had any operator-manifests archive, add that too.
operator = self._get_operator_item(nvr, meta, archives)
operator = self._get_operator_item(nvr, meta, archives, out)
if operator:
out.append(operator)

Expand Down Expand Up @@ -616,38 +616,41 @@ def _push_items_from_vmi_build(self, nvr, meta):

return out

def _get_operator_item(self, nvr, meta, archives):
def _get_operator_item(self, nvr, meta, archives, container_items):
extra = meta.get("extra") or {}
typeinfo = extra.get("typeinfo") or {}
operator_manifests = typeinfo.get("operator-manifests") or {}
archive_name = operator_manifests.get("archive")
operator_archive_name = operator_manifests.get("archive")
image = typeinfo.get("image") or {}
image_operator_manifests = image.get("operator_manifests") or {}
related_images = image_operator_manifests.get("related_images") or {}
pullspecs = related_images.get("pullspecs") or []
operator_related_images = [spec["new"] for spec in pullspecs if spec.get("new")]

if not archive_name:
if not operator_archive_name:
# Try legacy form
archive_name = extra.get("operator_manifests_archive")
operator_archive_name = extra.get("operator_manifests_archive")

if not archive_name:
if not operator_archive_name:
# No operator manifests on this build
return

operator_archive = [a for a in archives if a["filename"] == archive_name]
operator_archive = [
a for a in archives if a["filename"] == operator_archive_name
]
if len(operator_archive) != 1:
message = (
"koji build %s metadata refers to missing operator-manifests "
'archive "%s"'
) % (nvr, archive_name)
) % (nvr, operator_archive_name)
raise ValueError(message)

return OperatorManifestPushItem(
name=os.path.join(nvr, archive_name),
name=os.path.join(nvr, operator_archive_name),
dest=self._dest,
build=nvr,
related_images=operator_related_images,
container_image_items=container_items,
)

def _rpm_futures(self):
Expand Down
8 changes: 8 additions & 0 deletions src/pushsource/_impl/model/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,11 @@ class OperatorManifestPushItem(PushItem):
:type: List[str]
"""

container_image_items = attr.ib(
type=list, default=attr.Factory(frozenlist), converter=frozenlist
)
"""List of related container image push items.
:type: List[ContainerImagePushItem]
"""
Loading

0 comments on commit b05b7e8

Please sign in to comment.