Skip to content

Commit 4f10803

Browse files
committed
supervisor: add get_erratum_build_nvr
Add a function to get the NVR of a package in an erratum; we'll this to identify a particular package build from a previous erratum to run baseline tests against.
1 parent fb75a18 commit 4f10803

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

supervisor/errata_utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,31 @@ def is_previous_erratum_applicable(erratum_version: str, erratum: Erratum):
356356
cur_version = cur_version.parent
357357

358358

359+
def get_erratum_build_nvr(erratum_id: str | int, package_name: str) -> str | None:
360+
"""
361+
Gets the build NVR for a package in an erratum.
362+
363+
Args:
364+
erratum_id: The ID of the erratum.
365+
package_name: The name of the package for which to find the build NVR.
366+
367+
Returns:
368+
The build NVR for the package in the erratum, or None if not found. If
369+
the package is included in multiple releases within the erratum, returns
370+
the first one found. We do not expect builds for multiple product
371+
versions for the errata we are dealing with - that functionality is for
372+
products layered on top of RHEL that release to multiple RHEL versions.
373+
"""
374+
builds_by_release = ET_api_get(f"erratum/{erratum_id}/builds_list")
375+
for release_info in builds_by_release.values():
376+
for builds_map in release_info["builds"]:
377+
for build_nvr in builds_map:
378+
if build_nvr.rsplit("-", 2)[0] == package_name:
379+
return build_nvr
380+
381+
return None
382+
383+
359384
class RuleParseError(Exception):
360385
pass
361386

0 commit comments

Comments
 (0)