kojismokydingo.tags

Koji Smoky Dingo - tags and targets

author:

Christopher O'Brien <obriencj@gmail.com>

license:

GPL v3

collect_tag_extras(session, tag, prefix=None)[source]

Similar to session.getBuildConfig but with additional information recording which tag in the inheritance supplied the setting.

Returns an dict of tag extra settings, keyed by the name of the setting. Each setting is represented as its own dict composed of the following keys:

  • name - the extra setting key

  • value - the extra setting value

  • blocked - whether the setting represents a block

  • tag_name - the name of the tag this setting came from

  • tag_id - the ID of the tag this setting came from

Parameters:
  • session (ClientSession) -- an active koji client session

  • tag (int | str | TagInfo) -- koji tag info dict, or tag name

  • prefix (str | None) -- Extra name prefix to select for. If set, only tag extra fields whose key starts with the prefix string will be collected. Default, collect all.

Since:

1.0

Return type:

Dict[str, DecoratedTagExtra]

convert_tag_extras(taginfo, into=None, prefix=None)[source]

Provides a merged view of the tag extra settings for a tag. The extras are decorated with additional keys:

  • name - str, the name of the setting

  • blocked - bool, whether the setting is blocked

  • tag_name - str, the name of the tag that provided this setting

  • tag_id - int, the ID of the tag that provided this setting

When into is not None, then only settings which are not already present in that dict will be set. This behavior is used by collect_tag_extras to merge the extra settings across a tag and all its parents into a single dict.

Parameters:
  • taginfo (TagInfo) -- A koji tag info dict

  • into (dict | None) -- Existing dict to collect extras into. Default, create a new dict.

  • prefix (str | None) -- Only gather and convert extras with keys having this prefix. Default, gather all keys not already found.

Since:

1.0

Return type:

Dict[str, DecoratedTagExtra]

ensure_tag(session, name)[source]

Given a name, resolve it to a tag info dict. If there is no such tag, then create it and return its newly created tag info.

Parameters:
  • session (ClientSession) -- active koji session

  • name (str) -- tag name

Since:

1.0

Return type:

TagInfo

find_inheritance_parent(inheritance, parent_id)[source]

Find the parent link in the inheritance list with the given tag ID.

Parameters:
  • inheritance (List[TagInheritanceEntry]) -- the output of a getFullInheritance call

  • parent_id (int) -- the ID of a parent tag to look for in the inheritance data.

Returns:

matching inheritance link data, or None if none are found with the given parent_id

Since:

1.0

Return type:

TagInheritanceEntry

gather_affected_targets(session, tagnames)[source]

Returns the list of target info dicts representing the targets which inherit any of the given named tags. That is to say, the targets whose build tags are children of the named tags.

This list allows us to gauge what build configurations would be impacted by changes to the given tags.

Parameters:
Raises:

NoSuchTag -- if any of the names do not resolve to a tag info

Since:

1.0

Return type:

List[TargetInfo]

gather_tag_ids(session, shallow=None, deep=None, results=None)[source]

Load IDs from shallow tags, and load IDs from deep tags and all their parents. Returns a set of all IDs found.

If results is specified, it must be a set instance into which the disovered tag IDs will be added. Otherwise a new set will be allocated and returned.

Parameters:
  • session (ClientSession) -- an active koji client session

  • shallow (Iterable[str | int] | None) -- list of tag names to resolve IDs for

  • deep (Iterable[str | int] | None) -- list of tag names to resolve IDs and parent IDs for

  • results (set | None) -- storage for resolved IDs. Default, create a new set

Since:

1.0

Return type:

Set[int]

renum_inheritance(inheritance, begin=0, step=10)[source]

Create a new copy of the tag inheritance data with the priority values renumbered. Ordering is preserved.

Parameters:
  • inheritance (List[TagInheritanceEntry]) -- Inheritance structure data

  • begin (int) -- Starting point for renumbering priority values. Default, 0

  • step (int) -- Priority value increment for each priority after the first. Default, 10

Since:

1.0

Return type:

List[TagInheritanceEntry]

resolve_tag(session, name, target=False)[source]

Given a name, resolve it to a taginfo.

If target is False, name is treated as a tag's name.

If target is True, name is treated as a target's name, and the resulting taginfo will be from that target's build tag.

Parameters:
  • session (ClientSession) -- active koji session

  • name (int | str) -- Tag or Target name

  • target (bool) -- if True then name specifies a target rather than a tag, so fetch the build tag name from the target and look up that. Default False; name specifies a tag.

Raises:
  • NoSuchTag -- if the tag could not be resolved

  • NoSuchTarget -- if target is True and name cannot be resolved as a target

Since:

1.0

Return type:

TagInfo

tag_dedup(tag_infos)[source]

Given a sequence of tag info dictionaries, return a de-duplicated list of same, with order preserved.

All None infos will be dropped.

Parameters:

tag_infos (Iterable[TagInfo]) -- tag infos to be de-duplicated.

Since:

1.0

Return type:

Iterable[TagInfo]