Adjustments based on code review feedback
This commit is contained in:
parent
c46b11bac1
commit
1eaf5b18dd
9 changed files with 30 additions and 19 deletions
|
@ -206,14 +206,8 @@ def test_get_or_create_manifest_list(initialized_db):
|
||||||
v2_manifest = v2_builder.build()
|
v2_manifest = v2_builder.build()
|
||||||
|
|
||||||
# Write the manifests as blobs.
|
# Write the manifests as blobs.
|
||||||
location = ImageStorageLocation.get(name='local_us')
|
_populate_blob(v1_manifest.bytes)
|
||||||
blob = store_blob_record_and_temp_link('devtable', 'newrepo', v1_manifest.digest, location,
|
_populate_blob(v2_manifest.bytes)
|
||||||
len(v1_manifest.bytes), 120)
|
|
||||||
storage.put_content(['local_us'], get_layer_path(blob), v1_manifest.bytes)
|
|
||||||
|
|
||||||
blob = store_blob_record_and_temp_link('devtable', 'newrepo', v2_manifest.digest, location,
|
|
||||||
len(v2_manifest.bytes), 120)
|
|
||||||
storage.put_content(['local_us'], get_layer_path(blob), v2_manifest.bytes)
|
|
||||||
|
|
||||||
# Build the manifest list.
|
# Build the manifest list.
|
||||||
list_builder = DockerSchema2ManifestListBuilder()
|
list_builder = DockerSchema2ManifestListBuilder()
|
||||||
|
|
|
@ -4,9 +4,13 @@ from six import add_metaclass
|
||||||
@add_metaclass(ABCMeta)
|
@add_metaclass(ABCMeta)
|
||||||
class ManifestInterface(object):
|
class ManifestInterface(object):
|
||||||
""" Defines the interface for the various manifests types supported. """
|
""" Defines the interface for the various manifests types supported. """
|
||||||
|
@abstractproperty
|
||||||
|
def is_manifest_list(self):
|
||||||
|
""" Returns whether this manifest is a list. """
|
||||||
|
|
||||||
@abstractproperty
|
@abstractproperty
|
||||||
def schema_version(self):
|
def schema_version(self):
|
||||||
""" The version of the schema, or None for lists. """
|
""" The version of the schema. """
|
||||||
|
|
||||||
@abstractproperty
|
@abstractproperty
|
||||||
def digest(self):
|
def digest(self):
|
||||||
|
|
|
@ -206,6 +206,10 @@ class DockerSchema1Manifest(ManifestInterface):
|
||||||
if not verified:
|
if not verified:
|
||||||
raise InvalidSchema1Signature()
|
raise InvalidSchema1Signature()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_manifest_list(self):
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schema_version(self):
|
def schema_version(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -183,10 +183,14 @@ class DockerSchema2ManifestList(ManifestInterface):
|
||||||
except ValidationError as ve:
|
except ValidationError as ve:
|
||||||
raise MalformedSchema2ManifestList('manifest data does not match schema: %s' % ve)
|
raise MalformedSchema2ManifestList('manifest data does not match schema: %s' % ve)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_manifest_list(self):
|
||||||
|
""" Returns whether this manifest is a list. """
|
||||||
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schema_version(self):
|
def schema_version(self):
|
||||||
""" The version of the schema, or None for lists. """
|
return 2
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def digest(self):
|
def digest(self):
|
||||||
|
|
|
@ -140,6 +140,10 @@ class DockerSchema2Manifest(ManifestInterface):
|
||||||
if layer.is_remote and not layer.urls:
|
if layer.is_remote and not layer.urls:
|
||||||
raise MalformedSchema2Manifest('missing `urls` for remote layer')
|
raise MalformedSchema2Manifest('missing `urls` for remote layer')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_manifest_list(self):
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schema_version(self):
|
def schema_version(self):
|
||||||
return 2
|
return 2
|
||||||
|
|
|
@ -75,8 +75,6 @@ def test_valid_manifestlist():
|
||||||
|
|
||||||
manifestlist = DockerSchema2ManifestList(MANIFESTLIST_BYTES)
|
manifestlist = DockerSchema2ManifestList(MANIFESTLIST_BYTES)
|
||||||
assert len(manifestlist.manifests(_get_manifest)) == 2
|
assert len(manifestlist.manifests(_get_manifest)) == 2
|
||||||
assert (manifestlist.digest ==
|
|
||||||
'sha256:340d7dadea77035533a2d43e8ff711ecca1965978a6e7699b87e32b35f76038d')
|
|
||||||
|
|
||||||
assert manifestlist.media_type == 'application/vnd.docker.distribution.manifest.list.v2+json'
|
assert manifestlist.media_type == 'application/vnd.docker.distribution.manifest.list.v2+json'
|
||||||
assert manifestlist.bytes == MANIFESTLIST_BYTES
|
assert manifestlist.bytes == MANIFESTLIST_BYTES
|
||||||
|
@ -108,8 +106,6 @@ def test_get_v1_compatible_manifest_no_matching_list():
|
||||||
|
|
||||||
manifestlist = DockerSchema2ManifestList(NO_AMD_MANIFESTLIST_BYTES)
|
manifestlist = DockerSchema2ManifestList(NO_AMD_MANIFESTLIST_BYTES)
|
||||||
assert len(manifestlist.manifests(_get_manifest)) == 1
|
assert len(manifestlist.manifests(_get_manifest)) == 1
|
||||||
assert (manifestlist.digest ==
|
|
||||||
'sha256:40ed1cfe692333bfa519a9bfed9676975a990fff5afd35efa628320c39c793ca')
|
|
||||||
|
|
||||||
assert manifestlist.media_type == 'application/vnd.docker.distribution.manifest.list.v2+json'
|
assert manifestlist.media_type == 'application/vnd.docker.distribution.manifest.list.v2+json'
|
||||||
assert manifestlist.bytes == NO_AMD_MANIFESTLIST_BYTES
|
assert manifestlist.bytes == NO_AMD_MANIFESTLIST_BYTES
|
||||||
|
|
|
@ -72,5 +72,5 @@ export class ManifestSecurityView {
|
||||||
securityStatus.loading = false;
|
securityStatus.loading = false;
|
||||||
securityStatus.hasError = true;
|
securityStatus.hasError = true;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,8 @@ class V2Protocol(RegistryProtocol):
|
||||||
# Parse the returned manifest list and ensure it matches.
|
# Parse the returned manifest list and ensure it matches.
|
||||||
assert response.headers['Content-Type'] == DOCKER_SCHEMA2_MANIFESTLIST_CONTENT_TYPE
|
assert response.headers['Content-Type'] == DOCKER_SCHEMA2_MANIFESTLIST_CONTENT_TYPE
|
||||||
manifest = parse_manifest_from_bytes(response.text, response.headers['Content-Type'])
|
manifest = parse_manifest_from_bytes(response.text, response.headers['Content-Type'])
|
||||||
assert manifest.schema_version is None
|
assert manifest.schema_version == 2
|
||||||
|
assert manifest.is_manifest_list
|
||||||
assert manifest.digest == manifestlist.digest
|
assert manifest.digest == manifestlist.digest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,13 +83,17 @@ class BrokenManifest(ManifestInterface):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schema_version():
|
def schema_version(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def layers_compressed_size():
|
def layers_compressed_size(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_manifest_list(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class ManifestBackfillWorker(Worker):
|
class ManifestBackfillWorker(Worker):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Reference in a new issue