Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

class Command(BaseCommand):
"""
A django management command to initialize flags describing the image nature.
A management command to handle the initialization of empty DB fields for container images.

This command now initializes flags describing the image nature.

Manifests stored inside Pulp are of various natures. The nature of an image can be determined
from JSON-formatted image manifest annotations or image configuration labels. These data are
Expand All @@ -30,17 +32,25 @@ class Command(BaseCommand):
help = _(__doc__)

def handle(self, *args, **options):
manifests_updated_count = 0

manifests = Manifest.objects.exclude(
media_type__in=[MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.INDEX_OCI, MEDIA_TYPE.MANIFEST_V1]
).order_by("pulp_id")
self.update_manifests(manifests)
manifests_updated_count += self.update_manifests(manifests)

manifest_lists = Manifest.objects.filter(
media_type__in=[MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.INDEX_OCI]
).order_by("pulp_id")
self.update_manifests(manifest_lists)
manifests_updated_count += self.update_manifests(manifest_lists)

self.stdout.write(
self.style.SUCCESS("Successfully handled %d manifests." % manifests_updated_count)
)

def update_manifests(self, manifests_qs):
manifests_updated_count = 0

paginator = Paginator(manifests_qs, PAGE_CHUNK_SIZE)
for page_num in paginator.page_range:
manifests_to_update = []
Expand All @@ -59,3 +69,7 @@ def update_manifests(self, manifests_qs):
manifests_to_update,
fields_to_update,
)

manifests_updated_count += len(manifests_to_update)

return manifests_updated_count
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

def print_warning_for_initializing_image_nature(apps, schema_editor):
warnings.warn(
"Run 'pulpcore-manager init-image-nature' to initialize and expose metadata (i.e., "
"annotations and labels) for all manifests."
"Run 'pulpcore-manager container-handle-image-data' to initialize and expose metadata "
"(i.e., annotations and labels) for all manifests."
)


Expand Down