Add schema2 list support

This commit is contained in:
Joseph Schorr 2018-04-16 17:22:25 +03:00
parent 52b12131f7
commit a73cd9170a
7 changed files with 320 additions and 48 deletions

View file

@ -3,7 +3,6 @@ import logging
import hashlib
from collections import namedtuple
from jsonschema import validate as validate_schema, ValidationError
from digest import digest_tools
@ -133,6 +132,10 @@ class DockerSchema2Manifest(object):
except ValidationError as ve:
raise MalformedSchema2Manifest('manifest data does not match schema: %s' % ve)
@property
def schema_version(self):
return 2
@property
def config(self):
config = self._parsed[DOCKER_SCHEMA2_MANIFEST_CONFIG_KEY]
@ -160,7 +163,7 @@ class DockerSchema2Manifest(object):
except digest_tools.InvalidDigestException:
raise MalformedSchema2Manifest('could not parse manifest digest: %s' %
layer[DOCKER_SCHEMA2_MANIFEST_DIGEST_KEY])
yield DockerV2ManifestLayer(index=index,
size=layer[DOCKER_SCHEMA2_MANIFEST_SIZE_KEY],
digest=digest,
@ -192,6 +195,10 @@ class DockerSchema2Manifest(object):
digest SHA, returns the associated configuration JSON bytes for this schema.
"""
config_bytes = lookup_config_fn(self.config.digest)
if len(config_bytes) != self.config.size:
raise MalformedSchema2Manifest('Size of config does not match that retrieved: %s vs %s',
len(config_bytes), self.config.size)
schema2_config = DockerSchema2Config(config_bytes)
# Build the V1 IDs for the layers.