RSPImageCollection#

class controller.models.domain.rspimage.RSPImageCollection(images, cycle=None)#

Bases: object

Provides operations on a collection of RSPImage objects.

Parameters:

Methods Summary

add(image)

Add an image to the collection.

all_images(*[, hide_aliased, ...])

All images in sorted order.

image_for_digest(digest)

Find an image by digest.

image_for_tag_name(tag)

Find an image by tag name.

latest(image_type)

Get the latest image of a given type.

mark_image_seen_on_node(digest, node[, ...])

Mark an image as seen on a node.

subset(*[, releases, weeklies, dailies, include])

Return a subset of the image collection.

subtract(other)

Find the list of images in this collection missing from another.

Methods Documentation

add(image)#

Add an image to the collection.

If this has the same digest as an image already in the collection, the newly added image will replace the old one for image_for_digest purposes.

Parameters:

image (RSPImage) – The image to add.

Return type:

None

all_images(*, hide_aliased=False, hide_resolved_aliases=False)#

All images in sorted order.

Parameters:
  • hide_aliased (bool, default: False) – If True, hide images that are the primary target of an alias tag in the same collection. This is used for menu generation to suppress a duplicate entry for an image that already appeared earlier in the menu under an alias. We do not suppress images with the same digest that are aliased by the alias tag but are not its primary target, on the somewhat tenuous grounds that the description of the alias will not mention that image and it may seem strange for it to go missing.

  • hide_resolved_aliases (bool, default: False) – If True, hide images that are an alias for another image in the collection (but keep alias images when we don’t have the target). This is used to suppress the alias images when reporting prepull status, where the underlying images are more useful to report.

Returns:

Images sorted by their type and then in reverse by their version.

Return type:

list of RSPImage

image_for_digest(digest)#

Find an image by digest.

Returns the non-alias image by preference, although if an alias image has not been resolved with a target, we may return the unresolved alias.

Returns:

The image for that digest if found, otherwise None.

Return type:

RSPImage or None

Parameters:

digest (str) –

image_for_tag_name(tag)#

Find an image by tag name.

Returns:

The image with that tag name if found, otherwise None.

Return type:

RSPImage or None

Parameters:

tag (str) –

latest(image_type)#

Get the latest image of a given type.

Parameters:

image_type (RSPImageType) – Image type to retrieve.

Returns:

Latest image of that type, if any.

Return type:

RSPImage or None

mark_image_seen_on_node(digest, node, image_size=None)#

Mark an image as seen on a node.

This is implemented by the image collection so that we can update all of the image’s aliases as well.

Parameters:
  • digest (str) – Digest of image seen.

  • node (str) – Name of the node the image was seen on.

  • image_size (int | None, default: None) – If given, the observed image size, used to update the images.

Return type:

None

subset(*, releases=0, weeklies=0, dailies=0, include=None)#

Return a subset of the image collection.

Parameters:
  • releases (int, default: 0) – Number of releases to include.

  • weeklies (int, default: 0) – Number of weeklies to include.

  • dailies (int, default: 0) – Number of dailies to include.

  • include (set[str] | None, default: None) – Include this list of tags even if they don’t meet other criteria.

Returns:

The desired subset.

Return type:

RSPImageCollection

subtract(other)#

Find the list of images in this collection missing from another.

This returns only one image per digest, preferring the non-alias images, since the intended use is for determining what images to prepull, and there’s no need to prepull the same image more than once under different names.

Parameters:

other (RSPImageCollection) – The other collection, whose contents will be subtracted from this one.

Returns:

All images found in this collection that weren’t in the other. Images are considered matching only if their digests match.

Return type:

RSPImageCollection