From 9095a079f9bca35a66f0a70b0d095c495d0b7aa8 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Tue, 31 May 2022 21:07:10 -0400 Subject: [PATCH] Add ability to check if package exists in Koji Previously, the check_koji_build only allowed checking if a package build existed within a tag, this allows checking if the build exists in Koji anywhere. --- obal/data/modules/check_koji_build.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/obal/data/modules/check_koji_build.py b/obal/data/modules/check_koji_build.py index 23008cac..c8dc7483 100644 --- a/obal/data/modules/check_koji_build.py +++ b/obal/data/modules/check_koji_build.py @@ -11,7 +11,7 @@ def main(): """ module = AnsibleModule( argument_spec=dict( - tag=dict(type='str', required=True), + tag=dict(type='str', required=False), nevr=dict(type='str', required=True), package=dict(type='str', required=True), koji_executable=dict(type='str', required=False) @@ -23,13 +23,20 @@ def main(): package = module.params['package'] koji_executable = module.params['koji_executable'] - command = ['latest-build', '--quiet', tag, package] - try: - build = koji(command, koji_executable) - build = build.split(' ')[0] + if tag: + command = ['latest-build', '--quiet', tag, package] + build = koji(command, koji_executable) + build = build.split(' ')[0] + + module.exit_json(changed=False, tagged_version=build, exists=(nevr == build)) + else: + command = ['buildinfo', nevr] + output = koji(command, koji_executable) + exists = 'No such build' not in output + + module.exit_json(changed=False, exists=exists) - module.exit_json(changed=False, tagged_version=build, exists=(nevr == build)) except KojiCommandError as error: module.fail_json(changed=False, msg=error.message, command=error.command)