Add compressed_size to both schema formats on their layers
This commit is contained in:
parent
6c5c2f1a75
commit
c92294c218
4 changed files with 14 additions and 7 deletions
|
@ -72,7 +72,8 @@ class InvalidSchema1Signature(ManifestException):
|
|||
pass
|
||||
|
||||
|
||||
class Schema1Layer(namedtuple('Schema1Layer', ['digest', 'v1_metadata', 'raw_v1_metadata'])):
|
||||
class Schema1Layer(namedtuple('Schema1Layer', ['digest', 'v1_metadata', 'raw_v1_metadata',
|
||||
'compressed_size'])):
|
||||
"""
|
||||
Represents all of the data about an individual layer in a given Manifest.
|
||||
This is the union of the fsLayers (digest) and the history entries (v1_compatibility).
|
||||
|
@ -319,7 +320,9 @@ class DockerSchema1Manifest(ManifestInterface):
|
|||
extracted = Schema1V1Metadata(v1_metadata['id'], v1_metadata.get('parent'),
|
||||
v1_metadata.get('created'), v1_metadata.get('comment'),
|
||||
command, labels)
|
||||
yield Schema1Layer(image_digest, extracted, metadata_string)
|
||||
|
||||
compressed_size = v1_metadata.get('Size')
|
||||
yield Schema1Layer(image_digest, extracted, metadata_string, compressed_size)
|
||||
|
||||
@property
|
||||
def _payload(self):
|
||||
|
|
|
@ -25,8 +25,9 @@ DOCKER_SCHEMA2_MANIFEST_URLS_KEY = 'urls'
|
|||
|
||||
# Named tuples.
|
||||
DockerV2ManifestConfig = namedtuple('DockerV2ManifestConfig', ['size', 'digest'])
|
||||
DockerV2ManifestLayer = namedtuple('DockerV2ManifestLayer', ['index', 'size', 'digest',
|
||||
'is_remote', 'urls'])
|
||||
DockerV2ManifestLayer = namedtuple('DockerV2ManifestLayer', ['index', 'digest',
|
||||
'is_remote', 'urls',
|
||||
'compressed_size'])
|
||||
|
||||
LayerWithV1ID = namedtuple('LayerWithV1ID', ['layer', 'v1_id', 'v1_parent_id'])
|
||||
|
||||
|
@ -191,7 +192,7 @@ class DockerSchema2Manifest(ManifestInterface):
|
|||
layer[DOCKER_SCHEMA2_MANIFEST_DIGEST_KEY])
|
||||
|
||||
yield DockerV2ManifestLayer(index=index,
|
||||
size=layer[DOCKER_SCHEMA2_MANIFEST_SIZE_KEY],
|
||||
compressed_size=layer[DOCKER_SCHEMA2_MANIFEST_SIZE_KEY],
|
||||
digest=digest,
|
||||
is_remote=is_remote,
|
||||
urls=layer.get(DOCKER_SCHEMA2_MANIFEST_URLS_KEY))
|
||||
|
|
|
@ -62,13 +62,13 @@ def test_valid_manifest():
|
|||
|
||||
assert len(manifest.layers) == 4
|
||||
assert manifest.layers[0].is_remote
|
||||
assert manifest.layers[0].size == 1234
|
||||
assert manifest.layers[0].compressed_size == 1234
|
||||
assert str(manifest.layers[0].digest) == 'sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736'
|
||||
assert manifest.layers[0].urls
|
||||
|
||||
assert manifest.leaf_layer == manifest.layers[3]
|
||||
assert not manifest.leaf_layer.is_remote
|
||||
assert manifest.leaf_layer.size == 73109
|
||||
assert manifest.leaf_layer.compressed_size == 73109
|
||||
|
||||
blob_digests = list(manifest.blob_digests)
|
||||
assert len(blob_digests) == len(manifest.layers)
|
||||
|
|
|
@ -77,6 +77,9 @@ def test_valid_manifest():
|
|||
assert manifest.layers[1].v1_metadata.image_id == 'someid'
|
||||
assert manifest.layers[1].v1_metadata.parent_image_id == 'anotherid'
|
||||
|
||||
assert manifest.layers[0].compressed_size is None
|
||||
assert manifest.layers[1].compressed_size is None
|
||||
|
||||
assert manifest.leaf_layer == manifest.layers[1]
|
||||
assert manifest.created_datetime is None
|
||||
|
||||
|
|
Reference in a new issue