Enhancements for Docker schema implementations in preparing for supporting schema 2 in the OCI model

This adds additional required properties and methods to the Docker schema interface to allow us to treat both schema1 and schema2 manifests and lists logically equivalent from the OCI mode perspective
This commit is contained in:
Joseph Schorr 2018-11-12 23:27:01 +02:00
parent 6b86b87a16
commit e344d4a5cf
12 changed files with 447 additions and 22 deletions

View file

@ -1,4 +1,4 @@
from abc import ABCMeta, abstractproperty
from abc import ABCMeta, abstractproperty, abstractmethod
from six import add_metaclass
@add_metaclass(ABCMeta)
@ -26,7 +26,7 @@ class ManifestInterface(object):
@abstractproperty
def layers(self):
""" Returns the layers of this manifest, from base to leaf. """
""" Returns the layers of this manifest, from base to leaf or None if none. """
pass
@abstractproperty
@ -43,5 +43,34 @@ class ManifestInterface(object):
@abstractproperty
def blob_digests(self):
""" Returns an iterator over all the blob digests referenced by this manifest,
from base to leaf. The blob digests are strings with prefixes.
from base to leaf. The blob digests are strings with prefixes. For manifests that reference
config as a blob, the blob will be included here.
"""
@abstractmethod
def child_manifests(self, lookup_manifest_fn):
""" Returns an iterator of all manifests that live under this manifest, if any or None if none.
The lookup_manifest_fn is a function that, when given a blob content SHA, returns the
contents of that blob in storage if any or None if none.
"""
@abstractmethod
def get_manifest_labels(self, lookup_config_fn):
""" Returns a dictionary of all the labels defined inside this manifest or None if none. """
pass
@abstractmethod
def unsigned(self):
""" Returns an unsigned version of this manifest. """
@abstractmethod
def generate_legacy_layers(self, images_map, lookup_config_fn):
"""
Rewrites Docker v1 image IDs and returns a generator of DockerV1Metadata.
If Docker gives us a layer with a v1 image ID that already points to existing
content, but the checksums don't match, then we need to rewrite the image ID
to something new in order to ensure consistency.
Returns None if there are no legacy images associated with the manifest.
"""