def __init__(self, name, creds, transport, mount = None, threads = 1): """Constructor. If multiple threads are used, the caller *must* ensure that the provided transport is thread-safe, as well as the image that is being uploaded. It is notable that tarfile and httplib2.Http in Python are NOT threadsafe. Args: name: the fully-qualified name of the tag to push creds: provider for authorizing requests transport: the http transport to use for sending requests mount: list of repos from which to mount blobs. threads: the number of threads to use for uploads. Raises: ValueError: an incorrectly typed argument was supplied. """ self._name = name self._transport = docker_http.Transport(name, creds, transport, docker_http.PUSH) self._mount = mount self._threads = threads
def __enter__(self): # Create a v2 transport to use for making authenticated requests. self._transport = docker_http.Transport(self._name, self._creds, self._original_transport, docker_http.PULL) return self
def Delete(name, creds, transport): """Delete a tag or digest. Args: name: a docker_name.{Tag,Digest} to be deleted. creds: the docker_creds to use for deletion. transport: the transport to use to contact the registry. """ docker_transport = docker_http.Transport( name, creds, transport, docker_http.DELETE) if isinstance(name, docker_name.Tag): entity = name.tag else: assert isinstance(name, docker_name.Digest) entity = name.digest resp, unused_content = docker_transport.Request( '{scheme}://{registry}/v2/{repository}/manifests/{entity}'.format( scheme=docker_http.Scheme(name.registry), registry=name.registry, repository=name.repository, entity=entity), method='DELETE', accepted_codes=[httplib.OK])
def __init__(self, name, creds, transport, mount=None, threads=1): """Constructor. If multiple threads are used, the caller *must* ensure that the provided transport is thread-safe, as well as the image that is being uploaded. It is notable that tarfile and httplib2.Http in Python are NOT threadsafe. Args: name: docker_name.Tag, the fully-qualified name of the tag to push creds: docker_creds._CredentialProvider, provider for authorizing requests transport: httplib2.Http, the http transport to use for sending requests mount: list of docker_name.Repository, repos from which to mount blobs. threads: the number of threads to use for uploads. Raises: ValueError: an incorrectly typed argument was supplied. """ # TODO(user): Add support for pushing by manifest if not isinstance(name, docker_name.Tag): raise ValueError('Expected docker_name.Tag for "name"') if mount and not isinstance(mount, list): raise ValueError('Expected list of docker_name.Repository for "mount"') self._name = name self._transport = docker_http.Transport( name, creds, transport, docker_http.PUSH) self._mount = mount self._threads = threads
def __init__(self, name, creds, transport): """Constructor. Args: name: docker_name.Tag, the fully-qualified name of the tag to push creds: docker_creds._CredentialProvider, provider for authorizing requests transport: httplib2.Http, the http transport to use for sending requests Raises: ValueError: an incorrectly typed argument was supplied. """ # TODO(user): Add support for pushing by manifest if not isinstance(name, docker_name.Tag): raise ValueError('Expected docker_name.Tag for "name"') self._name = name self._transport = docker_http.Transport(name, creds, transport, docker_http.PUSH)
def Delete(name, creds, transport): """Delete a tag or digest. Args: name: a tag or digest to be deleted. creds: the credentials to use for deletion. transport: the transport to use to contact the registry. """ docker_transport = docker_http.Transport(name, creds, transport, docker_http.DELETE) _, unused_content = docker_transport.Request( '{scheme}://{registry}/v2/{repository}/manifests/{entity}'.format( scheme=docker_http.Scheme(name.registry), registry=name.registry, repository=name.repository, entity=_tag_or_digest(name)), method='DELETE', accepted_codes=[httplib.OK, httplib.ACCEPTED])