Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hyagi committed Nov 1, 2024
1 parent ec2d14e commit c9c8967
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
4 changes: 4 additions & 0 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ class ManifestListManifest(models.Model):
Manifest, related_name="manifest_lists", on_delete=models.CASCADE
)

def set_platform_configs(self, platform):
for key, value in platform.items():
setattr(self, key, value)

class Meta:
unique_together = ("image_manifest", "manifest_list")

Expand Down
7 changes: 1 addition & 6 deletions pulp_container/app/registry_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,12 +1224,7 @@ def put(self, request, path, pk=None):
image_manifest=manifest_list,
)
if platform := manifests[manifest.digest]:
manifest_to_list.architecture = (platform["architecture"],)
manifest_to_list.os = (platform["os"],)
manifest_to_list.features = (platform.get("features", ""),)
manifest_to_list.variant = (platform.get("variant", ""),)
manifest_to_list.os_version = (platform.get("os.version", ""),)
manifest_to_list.os_features = (platform.get("os.features", ""),)
manifest_to_list.set_platform_configs(platform)
manifests_to_list.append(manifest_to_list)

models.ManifestListManifest.objects.bulk_create(
Expand Down
22 changes: 7 additions & 15 deletions pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,19 +480,16 @@ async def create_listed_manifest(self, manifest_data):
manifest_url, digest
)

platform = {}
# in oci-index spec, platform is an optional field
if p := manifest_data.get("platform", None):
platform["architecture"] = p["architecture"]
platform["os"] = p["os"]
platform["features"] = p.get("features", "")
platform["variant"] = p.get("variant", "")
platform["os.version"] = p.get("os.version", "")
platform["os.features"] = p.get("os.features", "")
manifest.os = p["os"]
manifest.architecture = p["architecture"]
man_dc = DeclarativeContent(content=manifest)
return {"manifest_dc": man_dc, "platform": platform, "content_data": content_data}
return {
"manifest_dc": man_dc,
"platform": manifest_data.get("platform", None),
"content_data": content_data,
}

def create_blob(self, blob_data, deferred_download=True):
"""
Expand Down Expand Up @@ -644,13 +641,8 @@ def _post_save(self, batch):
manifest_list=manifest_dc.content,
image_manifest=dc.content,
)
if platform := listed_manifest.get("platform"):
manifest_list_manifest.architecture = platform["architecture"]
manifest_list_manifest.os = platform["os"]
manifest_list_manifest.features = platform.get("features")
manifest_list_manifest.variant = platform.get("variant")
manifest_list_manifest.os_version = platform.get("os.version")
manifest_list_manifest.os_features = platform.get("os.features")
if platform := listed_manifest.get("platform", None):
manifest_list_manifest.set_platform_configs(platform)
manifest_list_manifests.append(manifest_list_manifest)

if blob_manifests:
Expand Down

0 comments on commit c9c8967

Please sign in to comment.