-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add search function to look for builds by nvr; - We need this feature to ensure an update was complete successfully, and we don't need to reupload it. An example is if some fail occurs in the release job. Signed-off-by: Renata Ravanelli <[email protected]>
- Loading branch information
Showing
1 changed file
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,6 +406,32 @@ class _KojiBase(): | |
return session | ||
|
||
|
||
class Search(_KojiBase): | ||
""" | ||
Search for builds | ||
""" | ||
|
||
def __init__(self, profile): | ||
""" | ||
Creates a new instance for search. | ||
:param profile: Koji profile name in /etc/koji.conf.d | ||
:type str | ||
""" | ||
super().__init__(profile) | ||
|
||
def get_state(self, nvr): | ||
""" | ||
Return the build state. | ||
:param nvr: The nvr name from Brew | ||
""" | ||
|
||
info = self.session.getBuild(nvr, strict=False) | ||
if (info): | ||
return (info['state']) | ||
return 0 | ||
|
||
|
||
class Reserve(_KojiBase): | ||
""" | ||
Reserves a place in Koji for later archival. | ||
|
@@ -821,6 +847,11 @@ Examples: | |
--keytab keytab \ | ||
--owner [email protected] \ | ||
--profile koji | ||
$ cmd-koji-upload search \ | ||
--nvr nvr \ | ||
--keytab keytab \ | ||
--owner [email protected] \ | ||
--profile koji | ||
Environment variables are supported: | ||
- KOJI_USERNAME will set the owner | ||
|
@@ -867,6 +898,9 @@ Environment variables are supported: | |
upload_cmd = sub_commands.add_parser( | ||
"upload", help="Uploads to koji", parents=[parent_parser], add_help=False) | ||
|
||
search_cmd = sub_commands.add_parser( | ||
"search", help="Search for a build", parents=[parent_parser], add_help=False) | ||
|
||
sub_commands.add_parser( | ||
"reserve-id", help="Reserves a koji id", parents=[parent_parser], add_help=False) | ||
|
||
|
@@ -899,6 +933,10 @@ Environment variables are supported: | |
'--s3-url', required=False, | ||
help='Store url information in meta.json') | ||
|
||
search_cmd.add_argument( | ||
'--nvr', required=True, | ||
help='NVR to look for') | ||
|
||
args, extra_args = parser.parse_known_args() | ||
set_logger(args.log_level) | ||
|
||
|
@@ -915,7 +953,8 @@ Environment variables are supported: | |
|
||
if args.auth: | ||
kinit(args.keytab, args.owner) | ||
|
||
if args._command == 'search': | ||
print(Search(args.profile).get_state(args.nvr)) | ||
if args._command == 'upload': | ||
|
||
upload = Upload(build, args.owner, args.tag, args.profile) | ||
|