Change manifest creation to take in the map of blobs that form the manifest
We need to lookup the blobs *specific to the images in that manifest*, so we now pass them in from the locations in which we know that information
This commit is contained in:
parent
e3da522d26
commit
56222f95dc
8 changed files with 89 additions and 43 deletions
|
@ -65,15 +65,17 @@ def create_image(docker_image_id, repository_obj, username):
|
|||
|
||||
def store_tag_manifest(namespace, repo_name, tag_name, image_id):
|
||||
builder = DockerSchema1ManifestBuilder(namespace, repo_name, tag_name)
|
||||
storage_id_map = {}
|
||||
try:
|
||||
image_storage = ImageStorage.select().where(~(ImageStorage.content_checksum >> None)).get()
|
||||
builder.add_layer(image_storage.content_checksum, '{"id": "foo"}')
|
||||
storage_id_map[image_storage.content_checksum] = image_storage.id
|
||||
except ImageStorage.DoesNotExist:
|
||||
pass
|
||||
|
||||
manifest = builder.build(docker_v2_signing_key)
|
||||
manifest_row, _ = model.tag.store_tag_manifest_for_testing(namespace, repo_name, tag_name,
|
||||
manifest, leaf_layer_id=image_id)
|
||||
manifest, image_id, storage_id_map)
|
||||
return manifest_row
|
||||
|
||||
|
||||
|
|
|
@ -220,21 +220,37 @@ def test_change_tag_expiration(expiration_offset, expected_offset, initialized_d
|
|||
assert (expected_end_date - end_date).total_seconds() < 5 # variance in test
|
||||
|
||||
|
||||
def test_store_tag_manifest(initialized_db):
|
||||
def random_storages():
|
||||
return list(ImageStorage.select().where(~(ImageStorage.content_checksum >> None)).limit(10))
|
||||
|
||||
|
||||
def repeated_storages():
|
||||
storages = list(ImageStorage.select().where(~(ImageStorage.content_checksum >> None)).limit(5))
|
||||
return storages + storages
|
||||
|
||||
|
||||
@pytest.mark.parametrize('get_storages', [
|
||||
random_storages,
|
||||
repeated_storages,
|
||||
])
|
||||
def test_store_tag_manifest(get_storages, initialized_db):
|
||||
# Create a manifest with some layers.
|
||||
builder = DockerSchema1ManifestBuilder('devtable', 'simple', 'sometag')
|
||||
|
||||
storages = list(ImageStorage.select().where(~(ImageStorage.content_checksum >> None)).limit(10))
|
||||
storages = get_storages()
|
||||
assert storages
|
||||
|
||||
repo = model.repository.get_repository('devtable', 'simple')
|
||||
storage_id_map = {}
|
||||
for index, storage in enumerate(storages):
|
||||
image_id = 'someimage%s' % index
|
||||
builder.add_layer(storage.content_checksum, json.dumps({'id': image_id}))
|
||||
find_create_or_link_image(image_id, repo, 'devtable', {}, 'local_us')
|
||||
storage_id_map[storage.content_checksum] = storage.id
|
||||
|
||||
manifest = builder.build(docker_v2_signing_key)
|
||||
tag_manifest, _ = store_tag_manifest_for_testing('devtable', 'simple', 'sometag', manifest)
|
||||
tag_manifest, _ = store_tag_manifest_for_testing('devtable', 'simple', 'sometag', manifest,
|
||||
manifest.leaf_layer_v1_image_id, storage_id_map)
|
||||
|
||||
# Ensure we have the new-model expected rows.
|
||||
mapping_row = TagManifestToManifest.get(tag_manifest=tag_manifest)
|
||||
|
|
Reference in a new issue