Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
[noissue]

Init annotations for manifest list in sync task
Skip init_metadata for schema1.
  • Loading branch information
ipanova authored and lubosmj committed Mar 14, 2024
1 parent 52036b6 commit 10459c4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Command(BaseCommand):

def handle(self, *args, **options):
manifests = Manifest.objects.exclude(
media_type__in=[MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.INDEX_OCI]
media_type__in=[MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.INDEX_OCI, MEDIA_TYPE.MANIFEST_V1]
).order_by("pulp_id")
self.update_manifests(manifests)

Expand Down
3 changes: 3 additions & 0 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def init_metadata(self, manifest_data=None):
return has_annotations or has_labels or has_image_nature

def init_annotations(self, manifest_data=None):
# annotations are part of OCI only
if self.media_type not in (MEDIA_TYPE.MANIFEST_OCI, MEDIA_TYPE.INDEX_OCI):
return False
if manifest_data is None:
manifest_artifact = self._artifacts.get()
manifest_data, _ = get_content_data(manifest_artifact)
Expand Down
4 changes: 3 additions & 1 deletion pulp_container/app/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,9 @@ async def init_pending_content(self, digest, manifest_data, media_type, artifact
config_blob=config_blob,
)

await sync_to_async(manifest.init_metadata)(manifest_data=manifest_data)
# skip if media_type of schema1
if media_type in (MEDIA_TYPE.MANIFEST_V2, MEDIA_TYPE.MANIFEST_OCI):
await sync_to_async(manifest.init_metadata)(manifest_data=manifest_data)

try:
await manifest.asave()
Expand Down
5 changes: 4 additions & 1 deletion pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ def create_tagged_manifest_list(self, tag_name, saved_artifact, manifest_list_da
"""
digest = f"sha256:{saved_artifact.sha256}"
manifest_list = Manifest(
digest=digest, schema_version=manifest_list_data["schemaVersion"], media_type=media_type
digest=digest,
schema_version=manifest_list_data["schemaVersion"],
media_type=media_type,
annotations=manifest_list_data.get("annotations", {}),
)

manifest_list_dc = self._create_manifest_declarative_content(
Expand Down

0 comments on commit 10459c4

Please sign in to comment.