Skip to content

Commit

Permalink
Support parameters on token triggers
Browse files Browse the repository at this point in the history
Add missing parameters for token triggers. Esp used
for rebuild and release commands.
  • Loading branch information
adrianschroeter committed Oct 9, 2024
1 parent 8f10569 commit 5cf1f0f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
21 changes: 20 additions & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,16 @@ def do_showlinked(self, subcmd, opts, *args):
help='Trigger the action of a token')
@cmdln.option('', '--scm-token', metavar='SCM_TOKEN',
help='The scm\'s access token (only in combination with a --operation=workflow option)')
@cmdln.option('-a', '--arch', metavar='ARCH',
help='Release/Rebuild only binaries from the specified architecture')
@cmdln.option('-r', '--repo', metavar='REPO',
help='Release/Rebuild only binaries from the specified repository')
@cmdln.option('--target-project', metavar='TARGETPROJECT',
help='Release only to specified project')
@cmdln.option('--target-repository', metavar='TARGETREPOSITORY',
help='Release only to specified repository')
@cmdln.option('--set-release', metavar='RELEASETAG',
help='rename binaries during release using this release tag')
def do_token(self, subcmd, opts, *args):
"""
Show and manage authentication token
Expand Down Expand Up @@ -1731,7 +1741,16 @@ def do_token(self, subcmd, opts, *args):
print(status.to_string())
elif opts.trigger:
print("Trigger token")
status = obs_api.Token.do_trigger(apiurl, token=opts.trigger, project=project, package=package)
status = obs_api.Token.do_trigger(apiurl,
token=opts.trigger,
project=project,
package=package,
repository=opts.repo,
architecture=opts.arch,
target_project=opts.target_project,
target_repository=opts.target_repository,
set_release_to=opts.set_release
)

Check failure

Code scanning / CodeQL

Wrong name for an argument in a call Error

Keyword argument 'set_release_to' is not a supported parameter name of
method Token.do_trigger
.
print(status.to_string())
else:
if args and args[0] in ['create', 'delete', 'trigger']:
Expand Down
16 changes: 16 additions & 0 deletions osc/obs_api/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def do_trigger(
operation: Optional[str] = None,
project: Optional[str] = None,
package: Optional[str] = None,
repository: Optional[str] = None,
architecture: Optional[str] = None,
target_project: Optional[str] = None,
target_repository: Optional[str] = None,
set_release: Optional[str] = None,
):
if operation:
url_path = ["trigger", operation]
Expand All @@ -170,6 +175,17 @@ def do_trigger(
"package": package,
}

if repository is not None:
url_query["filter_source_repository"] = repository
if architecture is not None:
url_query["arch"] = architecture
if target_project is not None:
url_query["targetproject"] = target_project
if target_repository is not None:
url_query["targetrepository"] = target_repository
if set_release is not None:
url_query["setrelease"] = set_release

headers = {
"Content-Type": "application/octet-stream",
"Authorization": f"Token {token}",
Expand Down

0 comments on commit 5cf1f0f

Please sign in to comment.