56222f95dc
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
288 lines
8.6 KiB
Python
288 lines
8.6 KiB
Python
from abc import ABCMeta, abstractmethod
|
|
from collections import namedtuple
|
|
|
|
from namedlist import namedlist
|
|
from six import add_metaclass
|
|
|
|
|
|
class Repository(
|
|
namedtuple('Repository', [
|
|
'id', 'name', 'namespace_name', 'description', 'is_public', 'kind', 'trust_enabled'])):
|
|
"""
|
|
Repository represents a namespaced collection of tags.
|
|
:type id: int
|
|
:type name: string
|
|
:type namespace_name: string
|
|
:type description: string
|
|
:type is_public: bool
|
|
:type kind: string
|
|
:type trust_enabled: bool
|
|
"""
|
|
|
|
|
|
class ManifestJSON(namedtuple('ManifestJSON', ['digest', 'json', 'media_type'])):
|
|
"""
|
|
ManifestJSON represents a Manifest of any format.
|
|
"""
|
|
|
|
|
|
class Tag(namedtuple('Tag', ['id', 'name', 'repository'])):
|
|
"""
|
|
Tag represents a user-facing alias for referencing a set of Manifests.
|
|
"""
|
|
|
|
|
|
class BlobUpload(
|
|
namedlist('BlobUpload', [
|
|
'uuid', 'byte_count', 'uncompressed_byte_count', 'chunk_count', 'sha_state', 'location_name',
|
|
'storage_metadata', 'piece_sha_state', 'piece_hashes', 'repo_namespace_name', 'repo_name'])):
|
|
"""
|
|
BlobUpload represents the current state of an Blob being uploaded.
|
|
"""
|
|
|
|
|
|
class Blob(namedtuple('Blob', ['id', 'uuid', 'digest', 'size', 'locations', 'cas_path'])):
|
|
"""
|
|
Blob represents an opaque binary blob saved to the storage system.
|
|
"""
|
|
|
|
|
|
class RepositoryReference(namedtuple('RepositoryReference', ['id', 'name', 'namespace_name'])):
|
|
"""
|
|
RepositoryReference represents a reference to a Repository, without its full metadata.
|
|
"""
|
|
|
|
|
|
class Label(namedtuple('Label', ['key', 'value', 'source_type', 'media_type'])):
|
|
"""
|
|
Label represents a key-value pair that describes a particular Manifest.
|
|
"""
|
|
|
|
|
|
@add_metaclass(ABCMeta)
|
|
class DockerRegistryV2DataInterface(object):
|
|
"""
|
|
Interface that represents all data store interactions required by a Docker Registry v1.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def create_repository(self, namespace_name, repo_name, creating_user=None):
|
|
"""
|
|
Creates a new repository under the specified namespace with the given name. The user supplied is
|
|
the user creating the repository, if any.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_repository(self, namespace_name, repo_name):
|
|
"""
|
|
Returns a repository tuple for the repository with the given name under the given namespace.
|
|
Returns None if no such repository was found.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def has_active_tag(self, namespace_name, repo_name, tag_name):
|
|
"""
|
|
Returns whether there is an active tag for the tag with the given name under the matching
|
|
repository, if any, or none if none.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_manifest_by_tag(self, namespace_name, repo_name, tag_name):
|
|
"""
|
|
Returns the current manifest for the tag with the given name under the matching repository, if
|
|
any, or None if none.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_manifest_by_digest(self, namespace_name, repo_name, digest):
|
|
"""
|
|
Returns the manifest matching the given digest under the matching repository, if any, or None if
|
|
none.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete_manifest_by_digest(self, namespace_name, repo_name, digest):
|
|
"""
|
|
Deletes the manifest with the associated digest (if any) and returns all removed tags that
|
|
pointed to that manifest. If the manifest was not found, returns an empty list.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_docker_v1_metadata_by_tag(self, namespace_name, repo_name, tag_name):
|
|
"""
|
|
Returns the Docker V1 metadata associated with the tag with the given name under the matching
|
|
repository, if any. If none, returns None.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_docker_v1_metadata_by_image_id(self, repository, docker_image_ids):
|
|
"""
|
|
Returns a map of Docker V1 metadata for each given image ID, matched under the repository with
|
|
the given namespace and name. Returns an empty map if the matching repository was not found.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_parents_docker_v1_metadata(self, namespace_name, repo_name, docker_image_id):
|
|
"""
|
|
Returns an ordered list containing the Docker V1 metadata for each parent of the image with the
|
|
given docker ID under the matching repository. Returns an empty list if the image was not found.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def create_manifest_and_update_tag(self, namespace_name, repo_name, tag_name, manifest):
|
|
"""
|
|
Creates a new manifest and assigns the tag with the given name under the matching repository to
|
|
it.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def synthesize_v1_image(self, repository, storage, image_id, created, comment, command,
|
|
compat_json, parent_image_id):
|
|
"""
|
|
Synthesizes a V1 image under the specified repository, pointing to the given storage and returns
|
|
the V1 metadata for the synthesized image.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def save_manifest(self, repository, tag_name, manifest, blob_map):
|
|
"""
|
|
Saves a manifest, under the matching repository as a tag with the given name.
|
|
|
|
Returns a boolean whether or not the tag was newly created or not.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def repository_tags(self, namespace_name, repo_name, start_id, limit):
|
|
"""
|
|
Returns the active tags under the repository with the given name and namespace.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_visible_repositories(self, username, start_id, limit):
|
|
"""
|
|
Returns the repositories visible to the user with the given username, if any.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def create_blob_upload(self, namespace_name, repo_name, upload_uuid, location_name,
|
|
storage_metadata):
|
|
"""
|
|
Creates a blob upload under the matching repository with the given UUID and metadata.
|
|
Returns whether the matching repository exists.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def blob_upload_by_uuid(self, namespace_name, repo_name, upload_uuid):
|
|
"""
|
|
Searches for a blob upload with the given UUID under the given repository and returns it or None
|
|
if none.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def update_blob_upload(self, blob_upload):
|
|
"""
|
|
Saves any changes to the blob upload object given to the backing data store.
|
|
Fields that can change:
|
|
- uncompressed_byte_count
|
|
- piece_hashes
|
|
- piece_sha_state
|
|
- storage_metadata
|
|
- byte_count
|
|
- chunk_count
|
|
- sha_state
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete_blob_upload(self, namespace_name, repo_name, uuid):
|
|
"""
|
|
Deletes the blob upload with the given uuid under the matching repository. If none, does
|
|
nothing.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def mount_blob_and_temp_tag(self, namespace_name, repo_name, existing_blob, expiration_sec):
|
|
"""
|
|
Mounts an existing blob and links a temporary tag with the specified expiration to it under
|
|
the matching repository. Returns True on success and False on failure.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def create_blob_and_temp_tag(self, namespace_name, repo_name, blob_digest, blob_upload,
|
|
expiration_sec):
|
|
"""
|
|
Creates a blob and links a temporary tag with the specified expiration to it under the matching
|
|
repository.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_blob_by_digest(self, namespace_name, repo_name, digest):
|
|
"""
|
|
Returns the blob with the given digest under the matching repository or None if none.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def save_bittorrent_pieces(self, blob, piece_size, piece_bytes):
|
|
"""
|
|
Saves the BitTorrent piece hashes for the given blob.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def create_manifest_labels(self, namespace_name, repo_name, manifest_digest, labels):
|
|
"""
|
|
Creates a new labels for the provided manifest.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_blob_path(self, blob):
|
|
"""
|
|
Once everything is moved over, this could be in util.registry and not even touch the database.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def set_manifest_expires_after(self, namespace_name, repo_name, digest, expires_after_sec):
|
|
"""
|
|
Sets that the manifest with given digest expires after the number of seconds from *now*.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def lookup_blobs_by_digest(self, repository, digests):
|
|
"""
|
|
Looks up all blobs with the matching digests under the given repository.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def is_namespace_enabled(self, namespace_name):
|
|
""" Returns whether the given namespace is enabled. If the namespace doesn't exist,
|
|
returns True. """
|
|
pass
|
|
|
|
@abstractmethod
|
|
def is_repository_public(self, namespace_name, repo_name):
|
|
""" Returns True if the repository with the given name exists and is public. """
|
|
pass
|