dockerreg.models package

Submodules

dockerreg.models.v1 module

class dockerreg.models.v1.ImageV1(api, tag, repository, id=None)[source]

Bases: dockerreg.models.Image

ancestry()[source]
Returns:the list of layers that compose this image
Return type:list
get_layer()[source]
get_layer_desc()[source]
put_layer()[source]
put_layer_desc()[source]
class dockerreg.models.v1.ManifestV1(api, blob={}, raw='{}', media_type=None, repository=None, tag=None, id=None)[source]

Bases: dockerreg.models.Manifest

__init__(api, blob={}, raw='{}', media_type=None, repository=None, tag=None, id=None)[source]
architecture
config
container
container_config
created
docker_version
id
os
parent
refresh()[source]
size
verify()[source]
class dockerreg.models.v1.RegistryV1(api, name=None)[source]

Bases: dockerreg.models.Registry

__init__(api, name=None)[source]
get_namespaces(regexp=None)[source]
Parameters:regexp (str) – a regexp to filter the namespaces.
Returns:a list of namespaces in this registry, possibly filtered by regexp.
get_repositories(regexp=None)[source]
Parameters:regexp (str) – a regexp to filter the repositories
Returns:a dict of namespaces in this registry, possibly filtered by regexp.
class dockerreg.models.v1.RepositoryV1(api, repository, registry)[source]

Bases: dockerreg.models.Repository

dockerreg.models.v2 module

class dockerreg.models.v2.ImageV2(api, tag, repository, id=None, filebasename=None, arch=<function getgoarch>, oss=<function getgoos>)[source]

Bases: dockerreg.models.Image

__init__(api, tag, repository, id=None, filebasename=None, arch=<function getgoarch>, oss=<function getgoos>)[source]
check_layer(layer_id)[source]
copy_to(repository=None, tag=None, filebasename=None, lazy=True)[source]

Copies this image, possibly to a new repository (possibly registry) and/or tag. At least one of these values must be set; otherwise an IllegalArgumentError will be generated. Moreover, they must not be set to the same values as the image has; this will also result in an IllegalArgumentError.

:param dockerreg.models.Repository repository: a dockerreg.models.Repository object, specifying a new repository (and possibly a different Registry). :param str tag: a new tag to use for this image.

delete(layers=False)[source]
filebasename
get_layer_content(layer_id)[source]
id
layer_size(layer_id)[source]
manifest
pull(refresh=False)[source]
push()[source]
refresh()[source]
set_layer_content(layer_id, blob)[source]
set_manifest(manifest)[source]
size()[source]
validate(refresh=False)[source]
class dockerreg.models.v2.ManifestList(api, blob={}, repository=None)[source]

Bases: dockerreg.models.Model

__init__(api, blob={}, repository=None)[source]
get_platform_manifest(arch=<function getgoarch>, oss=<function getgoos>)[source]
class dockerreg.models.v2.ManifestListV22(api, blob={}, raw=None, media_type=None, repository=None, tag=None, id=None)[source]

Bases: dockerreg.models.v2.ManifestList

__init__(api, blob={}, raw=None, media_type=None, repository=None, tag=None, id=None)[source]
get_platform_manifest(arch=<function getgoarch>, oss=<function getgoos>)[source]
manifests
refresh()[source]
schema_version
class dockerreg.models.v2.ManifestV1Compat(api, blob={}, raw='{}', media_type=None, repository=None, tag=None, id=None)[source]

Bases: dockerreg.models.v1.ManifestV1

class dockerreg.models.v2.ManifestV21(api, blob={}, raw=None, media_type=None, repository=None, tag=None, id=None)[source]

Bases: dockerreg.models.Manifest, dockerreg.models.SignableMixin

__init__(api, blob={}, raw=None, media_type=None, repository=None, tag=None, id=None)[source]
architecture
copy_to(repository, tag)[source]
created
delete()[source]
digest
history
id
layers
modify(repository=None, tag=None)[source]
push()[source]
raw
refresh()[source]
schema_version
sign()[source]
signatures
verify()[source]
class dockerreg.models.v2.ManifestV22(api, blob={}, raw=None, media_type=None, repository=None, tag=None, id=None, manifest_list=None)[source]

Bases: dockerreg.models.Manifest

__init__(api, blob={}, raw=None, media_type=None, repository=None, tag=None, id=None, manifest_list=None)[source]
architecture
config
config_digest
config_media_type
config_size
created
digest
features
layers
manifest
manifest_list
media_type
os
os_features
os_version
refresh()[source]
repository
schema_version
size
variant
class dockerreg.models.v2.RegistryV2(api, name=None)[source]

Bases: dockerreg.models.Registry

__init__(api, name=None)[source]
check_image(repository, tag, arch=<function getgoarch>, oss=<function getgoos>)[source]
delete_image(repository, tag, layers=False, arch=<function getgoarch>, oss=<function getgoos>)[source]
delete_tag(repository, tag, arch=<function getgoarch>, oss=<function getgoos>)[source]
get_image_created(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None)[source]
get_image_metadata(repository, tag, arch=<function getgoarch>, oss=<function getgoos>)[source]

We return a dict of the reference metadata (manifest digest, length, repository name, reference/tag), and then of the image (total size, arch, layers (digest, size),

get_image_size(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None)[source]
get_namespaces(regexp=None)[source]
Returns:a list of namespaces in this registry.
Return type:list
get_reference_metadata(repository, reference)[source]
get_repositories(regexp=None, namespace_regexp=None)[source]
Returns:a dict of namespace-to-repository-lists in this registry.
Return type:dict
get_tags(repository, metadata=False)[source]
pull_and_push_image(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None, refresh=False, dst_registry=None, dst_repository=None, dst_tag=None, dst_username=None, dst_password=None, dst_no_verify=None, dst_cert=None, dst_ca_bundle=None, dst_skip_docker_config=False, dst_no_cache=False, dst_cache_file=None)[source]

Pulls the repository:tag image from this registry, and pushes it to dstregistry/dstrepository:dsttag. If all dst* parameters are None, an IllegalArgumentError will be raised. If any of the dst* parameters are unspecified, their values will be taken from the current values of the specified image. This allows you to simply re-tag an image; copy it to another repository; or copy it to another repository.

pull_image(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None, refresh=False)[source]

Pulls the image descriptor and all layers, returning an Image`representing the downloaded image.  If the `filebasename parameter is set, the raw data will be cached in files instead of in memory.

Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • tag (str) – the tag indicating the version of the image.
  • arch (str) – a GOARCH architecture string (i.e. amd64); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • filebasename (str) – if set, the image manifest and layers will be cached in files named filebasename.manifest and filebasename.<layer_id>. If the image already exists on disk via filebasename, it will be loaded from disk.
  • refresh (bool) – if set False (the default), and if the image exists on disk via filebasename, the image will not be refreshed (i.e., will not be re-pulled from the registry; only layers that are not cached in files will be pulled; the manifest will not be refreshed).
Returns:

a Image.

push_image(repository, tag, filebasename=None)[source]
tag_image(repository, tag, newtag, arch=<function getgoarch>, oss=<function getgoos>)[source]
class dockerreg.models.v2.RepositoryV2(api, repository, registry)[source]

Bases: dockerreg.models.Repository

__init__(api, repository, registry)[source]
get_image(tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None)[source]

Returns an Image`representing the requested image.  If the `filebasename parameter is set, any downloaded raw data will be cached in files instead of in memory.

Parameters:
  • tag (str) – the tag indicating the version of the image.
  • filebasename (str) – if set, the image manifest and layers will be cached in files named filebasename.manifest and filebasename.<layer_id>.
  • arch (str) – a GOARCH architecture string (i.e. amd64); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
Returns:

a Image.

get_reference_metadata(reference)[source]
get_tags(metadata=False)[source]
Returns:a list of tags in this repository.
refresh()[source]
dockerreg.models.v2.create_v2_manifest(api, blob, raw, repository=None, tag=None, id=None, content_type=None)[source]

Module contents

class dockerreg.models.Image(api, tag, repository, id=None)[source]

Bases: dockerreg.models.Model

__init__(api, tag, repository, id=None)[source]
deleted
size()[source]
Returns:the total size of the blobs/layers that make up the image.
Return type::type:`int`
tag
class dockerreg.models.Manifest(api, blob={}, raw='{}', media_type=None, repository=None, tag=None, id=None)[source]

Bases: dockerreg.models.Model

__init__(api, blob={}, raw='{}', media_type=None, repository=None, tag=None, id=None)[source]
media_type
modify(**kwargs)[source]

Modify this manifest. This could mean, for instance, for a v2-1 manifest, to change the repository and/or tag. It is manifest version-defined; but all Manifest subclasses should at least support the repository and tag modification keys.

raw
repository
tag
valid_media_types
verify()[source]
Returns:True if verified; None if there is nothing to verify; or throws an Exception if verification fails.
version
class dockerreg.models.Model(api, name, id=None)[source]

Bases: object

__init__(api, name, id=None)[source]
api

The dockerreg.api.BaseApiClient corresponding to this Model.

id

The identifier (a str) corresponding to this object, if any.

name

The name (a str) corresponding to this object.

refresh()[source]

Refreshes this object’s content from the registry.

Raises:dockerreg.exceptions.ObjectNotFoundError – if the object no longer exists at the registry.
class dockerreg.models.Registry(api, name)[source]

Bases: dockerreg.models.Model

__init__(api, name)[source]
authping()[source]
Returns:True if the registry is responding and the user is authenticated and authorized to the / URL (i.e. version check); False if not.
Return type:bool
check_image(repository, tag, arch=<function getgoarch>, oss=<function getgoos>)[source]

Ensures that the image and its layers are all present in the named repository at the given tag.

Parameters:
Returns:

0 if all layers are present in repository; non-zero otherwise.

delete_image(repository, tag, layers=False, arch=<function getgoarch>, oss=<function getgoos>)[source]

Deletes the image.

Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • tag (str) – the tag indicating the version of the image.
  • layers (bool) – True if we should delete layers; defaults to False.
  • arch (str) – a GOARCH architecture string (i.e. amd64); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
Returns:

None.

delete_tag(repository, tag, arch=<function getgoarch>, oss=<function getgoos>)[source]

Deletes a tag.

Parameters:
Returns:

None.

get_image_created(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None)[source]

Pulls the image descriptor to determine the creation time of the most recent layer (which is effectively the image creation time), returning an :type:`str` specifying created time. If the filebasename parameter is set, the raw data will be cached in files instead of in memory.

Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • tag (str) – the tag indicating the version of the image.
  • arch (str) – a GOARCH architecture string (i.e. amd64); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • filebasename (str) – if set, the image manifest (and any layers, if they are fully downloaded) will be cached in files named filebasename.manifest and filebasename.<layer_id>.
Returns:

an :type:`str` specifying created time.

get_image_metadata(repository, tag, arch=<function getgoarch>, oss=<function getgoos>)[source]
Parameters:
Returns:

an image metadata dict.

get_image_size(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None)[source]

Pulls the image descriptor and enough layer content to determine the total size of all layers in the image, returning an :type:`int` specifying the total layer size in bytes. If the filebasename parameter is set, the raw data will be cached in files instead of in memory.

Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • tag (str) – the tag indicating the version of the image.
  • arch (str) – a GOARCH architecture string (i.e. amd64); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • filebasename (str) – if set, the image manifest (and any layers, if they are fully downloaded) will be cached in files named filebasename.manifest and filebasename.<layer_id>.
Returns:

a Image.

get_namespaces(regexp=None)[source]

Return a list of namespaces in this registry, possibly filtered by regexp string.

Parameters:regexp (str) – a regexp to filter over
Returns:a list of namespaces in this registry, possibly filtered by regexp.
Return type:list
get_reference_metadata(repository, reference)[source]
Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • reference (str) – a manifest id or digest.
Returns:

a tag metadata dict.

get_repositories(regexp=None, namespace_regexp=None)[source]

Return a dict of namespaces-to-repository lists in this registry.

Parameters:
  • regexp (str) – a regexp to filter over
  • namespace_regexp (str) – a regexp to filter over namespaces
Returns:

a dict of namespaces, whose values are lists of repositories, in this registry, possibly filtered by regexp.

Return type:

dict

get_tags(repository, metadata=False)[source]
Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • metadata (str) – a boolean specifying to return tag metadata (i.e. its digest, manifest length, etc).
Returns:

a list of tags in this repository, or a list of tag metadata dict`s if :param metadata: is set to `True.

namespaces

A list of namespaces in this registry.

ping()[source]
Returns:True if the registry is responding; False if not.
Return type:bool
pull_and_push_image(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None, refresh=False, dst_registry=None, dst_repository=None, dst_tag=None, dst_username=None, dst_password=None, dst_no_verify=None, dst_cert=None, dst_ca_bundle=None, dst_skip_docker_config=False, dst_no_cache=False, dst_cache_file=None)[source]

Pulls the repository:tag image from this registry, and pushes it to dst_registry/dst_repository:dst_tag. If all dst* parameters are None, an IllegalArgumentError will be raised. If any of the dst* parameters are unspecified, their values will be taken from the current values of the specified image. This allows you to simply re-tag an image; copy it to another repository; or copy it to another repository.

pull_image(repository, tag, arch=<function getgoarch>, oss=<function getgoos>, filebasename=None)[source]

Pulls the image descriptor and all layers, returning an Image`representing the downloaded image.  If the `filebasename parameter is set, the raw data will be cached in files instead of in memory.

Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • tag (str) – the tag indicating the version of the image.
  • arch (str) – a GOARCH architecture string (i.e. amd64); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux); defaults to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • filebasename (str) – if set, the image manifest and layers will be cached in files named filebasename.manifest and filebasename.<layer_id>.
Returns:

a Image.

push_image(repository, tag, filebasename)[source]

Pushes the image referenced by filebasename to the given repository and tag.

Parameters:
  • repository (str) – the full name of the image, including the namespace and repository.
  • tag (str) – the tag indicating the version of the image.
  • filebasename (str) – if set, the image manifest and layers will be read from the cached copy in files named filebasename.manifest and filebasename.<layer_id>.
refresh()[source]
repositories

A dict of repositories in this registry, keyed by <namespace>/<repository> strings, with values dockerreg.models.Repository.

tag_image(repository, tag, newtag, arch=<function getgoarch>, oss=<function getgoos>)[source]

Applies a new tag to an existing image referenced by its tag.

Parameters:
Returns:

a Image.

class dockerreg.models.Repository(api, repository, registry)[source]

Bases: dockerreg.models.Model

__init__(api, repository, registry)[source]
get_image(tag, arch=None, oss=None, filebasename=None)[source]

Returns an Image`representing the requested image.  If the `filebasename parameter is set, any downloaded raw data will be cached in files instead of in memory.

Parameters:
  • tag (str) – the tag indicating the version of the image.
  • filebasename (str) – if set, the image manifest and layers will be cached in files named filebasename.manifest and filebasename.<layer_id>.
  • arch (str) – either None or a GOARCH architecture string (i.e. amd64). Some Registry versions support multi-platform images; if there is a choice, and if you do not specify a value, it will default to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
  • oss (str) – a GOOS operating system string (i.e. linux). Some Registry versions support multi-platform images; if there is a choice, and if you do not specify a value, it will default to the platform this library is running on; see https://golang.org/doc/install/source#environment for valid values.
Returns:

a Image.

get_reference_metadata(reference)[source]
Parameters:reference (str) – a manifest id or digest.
Returns:a tag metadata dict.
get_tags(metadata=False)[source]
Returns:a list of tags in this repository, or a list of tag metadata dict`s if :param metadata: is set to `True.
class dockerreg.models.SignableMixin[source]

Bases: object

sign()[source]

Updates the Manifest in place (specifically, updates the _raw instance variable (the raw property) with a new, signed raw manifest string, based on the current manifest attributes.