Push items

All push items provided by this library inherit from a common class documented here.

Every push item class has the following properties:

  • push item classes use attrs.

  • instances are immutable; use helper functions such as attr.evolve() to obtain a modified push item.

class pushsource.PushItem[source]

A PushItem represents a single piece of content to be published. This may be an RPM, an advisory, a generic file, and so on.

Attributes:

name

A name for this push item.

A push item’s name may be any short identifying string which is meaningful to end-users.

In the common case of a regular file, a push item name will simply be a filename, optionally including leading path components.

In all cases, a non-empty name must be provided.

Type:

str

state

The state of this push item.

In the majority of cases, push sources will produce push items with a state of PENDING, with the caller expected to later evolve the state.

In rare cases, push sources may produce push items with other states, such as INVALIDFILE to indicate that the source located invalid content.

Type:

str

src

The source of this push item.

If the push item is a file, this will be the full path to the file. If the push item does not represent a file, this will generally be omitted.

Type:

str

dest

Destination of this push item.

The meaning of “dest” differs depending on the source used and its configuration.

Examples for possible uses of “dest” include:

  • a path to a directory (for items pushed using rsync)

  • a Pulp repository name (for items pushed using Pulp)

Type:

list[str]

md5sum

Hex digest of MD5 checksum for this push item, if available.

See also

with_checksums()

Type:

str

sha256sum

Hex digest of SHA256 checksum for this push item, if available.

See also

with_checksums()

Type:

str

origin

A string representing the origin of this push item.

The “origin” field is expected to record some info on how this push item was discovered. The exact semantics depend on the specific source backend in use.

Type:

str

build

NVR for the koji build from which this push item was extracted, if any.

See also

build_info(), which provides the same info in parsed form.

Type:

str

build_info

Basic info on the koji build from which this push item was extracted, if any.

Type:

KojiBuildInfo

signing_key

If this push item was GPG signed, this should be an identifier for the signing key used.

Generally a short key ID such as “F21541EB” is used, though the library doesn’t enforce this.

Type:

str

with_checksums()[source]

Return a copy of this push item with checksums present.

Many pushsource backends will produce push items with empty checksum attributes, since checksum calculation may be expensive and may not be required in all cases.

The rule of thumb is that a pushsource will only provide checksums if they were available in metadata, so that reading the push item’s file was unnecessary. For example:

  • with errata push source, checksums are generally available by default, because Errata Tool itself provides checksums on the files contained in an advisory.

  • with staged push source, checksums are unavailable by default, because the sums can only be calculated by reading file content from the staging area.

Where checksums are needed, this utility method may be used to ensure they are present regardless of the push source used.

This method entails reading the entire content of the file referenced by this push item, and may be:

  • slow: may need to read a large file from a remote system, e.g. from an NFS volume.

  • error-prone: reads from a remote system might fail.

As such, when dealing with a large number of push items, you may want to consider using multiple threads to parallelize calls to with_checksums, and retrying failing operations.

If checksums are already present or if this item does not reference a file, this method is a no-op and returns the current push item, unmodified.

Returns:

PushItem

A copy of this item, guaranteed either to have non-empty md5sum() and sha256sum() attributes, or an empty src() attribute (denoting that the item does not reference a file).

New in version 1.2.0.

class pushsource.KojiBuildInfo[source]

A representation of a koji build.

Attributes:

name

‘name’ component of build’s NVR.

Example: in “kf5-kio-5.83.0-2.el8.next”, the name is “kf5-kio”.

Type:

str

version

‘version’ component of build’s NVR.

Example: in “kf5-kio-5.83.0-2.el8.next”, the version is “5.83.0”.

Type:

str

release

‘release’ component of build’s NVR.

Example: in “kf5-kio-5.83.0-2.el8.next”, the release is “2.el8.next”.

Type:

str

id

Optional attribute to store the ‘build_id’ from Koji.

Type:

int