Tag Docker

This is the main class for the Tag Docker workflow, which is used for adding and deleting tags and architectures.

class pubtools._quay.tag_docker.TagDocker(push_items: List[Any], hub: Any, task_id: str, target_name: str, target_settings: Dict[str, Any])[source]

Handle full tag-docker workflow.

__init__(push_items: List[Any], hub: Any, task_id: str, target_name: str, target_settings: Dict[str, Any]) None[source]

Initialize.

Args:
push_items ([_PushItem]):

List of push items.

hub (HubProxy):

Instance of XMLRPC pub-hub proxy.

task_id (str):

task id

target_name (str):

Name of the target.

target_settings (dict):

Target settings.

run() None[source]

Perform the full tag-docker workflow.

The workflow adds or removes images to/from given tags. It’s possible to specify only certain architectures to be added or removed. Based on the task arguments, five different scenarios may occur: - Copying whole image to tag (if tag is unused, or all its archs will be overwritten) - Copying only certain archs and adding them to the destination manifest list - Removing certain archs from a tag - Removing a tag (if all archs are to be removed from it) - No operation (to-be-removed tag already doesn’t exist, or all archs are restricted)

The workflow may be summarized as: - Verify that all repos may be worked with (same conditions are in PushDocker) - Evaluate which archs are to be added/removed from a given tag - If new images were created, perform signing workflow on them - Perform the appropriate add/remove/merge operation

quay_client()

Create and access QuayClient for source and dest images.

verify_target_settings() None[source]

Verify that target settings contains all the necessary data.

verify_input_data() None[source]

Verify that the data specified for the TagDocker operation are correct.

check_input_validity() None[source]

Check if input data satisfies tag-docker specific constraints.

The constraints are following: 1. If adding tags to prod target, these tags must already exist in stage target. 2. If removing tags from prod target, these tags must already not exist in stage target.

get_image_details(reference: str, executor: Executor) Optional[ImageDetails][source]

Create an ImageDetails namedtuple for the given image reference.

Args:
reference (str):

Image reference.

executor (Executor):

Instance of Executor subclass used for skopeo inspect.

Returns (Optional[ImageDetails]):

Namedtuple filled with images data, or None if image doesn’t exist.

is_arch_relevant(push_item: Any, arch: str) bool[source]

Find out if an operation should be performed on a given architecture.

Uses values of ‘archs’ and ‘exclude_archs’ in push item’s metadata.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

arch (str):

Arch to investigate.

Returns (bool):

True if an operation should be performed on a given arch, False otherwise.

tag_remove_calculate_archs(push_item: Any, tag: str, executor: Executor) Tuple[List[str], List[str]][source]

Calculate which architectures would be removed, and which would remain from a given tag.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

tag (str):

Tag, for which a ‘remove’ operation will be performed.

executor (Executor):

Instance of Executor subclass used for skopeo inspect.

Returns ([str], [str]):

Tuple where first element contains archs that will be removed, and second element contains archs that will remain.

tag_remove_calculate_archs_source_image(push_item: Any, source_details: Optional[ImageDetails], dest_details: ImageDetails) Tuple[List[str], List[str]][source]

Calculate which archs would be removed if the specified images were source images.

This method is a sub-step of the ‘tag_remove_calculate_archs’ method.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

source_details (Optional[ImageDetails]):

ImageDetails of source image, or None if it wasn’t specified.

dest_details (ImageDetails):

ImageDetails of destination image.

Returns ([str], [str]):

Tuple where first element contains archs that will be removed, and second element contains archs that will remain.

tag_remove_calculate_archs_multiarch_image(push_item: Any, source_details: Optional[ImageDetails], dest_details: ImageDetails) Tuple[List[str], List[str]][source]

Calculate which archs would be removed if the specified images were multiarch images.

This method is a sub-step of the ‘tag_remove_calculate_archs’ method.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

source_details (Optional[ImageDetails]):

ImageDetails of source image, or None if it wasn’t specified.

dest_details (ImageDetails):

ImageDetails of destination image.

Returns ([str], [str]):

Tuple where first element contains archs that will be removed, and second element contains archs that will remain.

tag_add_calculate_archs(push_item: Any, tag: str, executor: Executor) Optional[List[str]][source]

Calculate which architectures are present in a given tag, and which ones would be added.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

tag (str):

Tag, for which an ‘add’ operation will be performed.

executor (Executor):

Instance of Executor subclass used for skopeo inspect.

Returns (Optional[List[str]]):

In case of multiarch image, arches which would be copied to the destination. In case of a source image, None if the copy operation is relevant or [] otherwise.

copy_tag_sign_images(push_item: Any, tag: str, executor: Executor) None[source]

Copy image from source to the destination tag and sign new manifest claims.

If destination tag already contains a manifest, it will be overwritten. This workflow is expected to use on single-arch source images.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

tag (str):

Tag, which acts as a destination to the copy operation.

signature_handler (BasicSignatureHandler):

Instance of signature handler which will perform the signing.

executor (Executor):

Instance of Executor subclass used for skopeo inspect.

merge_manifest_lists_sign_images(push_item: Any, tag: str, add_archs: List[str]) None[source]

Merge manifest lists between source and destination tag and sign manifest claims.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

tag (str):

Tag, which acts as a destination to the merge operation.

add_archs ([str]):

Architectures which should be copied to the existing manifest list.

signature_handler (BasicSignatureHandler):

Instance of signature handler which will perform the signing.

classmethod run_untag_images(references: List[str], remove_last: bool, target_settings: Dict[str, Any]) None[source]

Prepare the “untag images” entrypoint with all the necessary arguments and run it.

Args:
references ([str]):

Image references which should be untagged.

remove_last (bool):

Whether to remove a tag when it’s the last reference of an image (in that repo).

target_settings (dict):

Settings used for setting the value of untag parameters.

untag_image(push_item: Any, tag: str) None[source]

Untag image specified by tag.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

tag (str):

Tag which should be removed.

manifest_list_remove_archs(push_item: Any, tag: str, remove_archs: List[str]) None[source]

Remove specified archs from a manifest list and upload a new manifest list to Quay.

Args:
push_item (ContainerPushItem):

Push item to perform the workflow with.

tag (str):

Tag whose manifest’s archs will be removed.

remove_archs ([str]):

Architectures to remove from the manifest list.