mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-24 11:12:14 +01:00
Add support for creating a workflow token via "osc token"
A workflow token can be created via "osc token --create --operation workflow --scm-token <SCM_TOKEN>". Triggering a workflow token via osc is probably unlikely - that's why it is not yet implemented (it would also make the UI a bit awkward because one has to specify a concrete http header). Fixes: #943 ("implement osc token --operation=workflow")
This commit is contained in:
parent
9eea35eda0
commit
d38d6a53a4
@ -771,9 +771,11 @@ class Osc(cmdln.Cmdln):
|
||||
@cmdln.option('-d', '--delete', metavar='TOKENID',
|
||||
help='Delete a token')
|
||||
@cmdln.option('-o', '--operation', metavar='OPERATION',
|
||||
help='Default is "runservice", but "branch", "release" or "rebuild" can also be used')
|
||||
help='Default is "runservice", but "branch", "release", "rebuild", or "workflow" can also be used')
|
||||
@cmdln.option('-t', '--trigger', metavar='TOKENSTRING',
|
||||
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)')
|
||||
def do_token(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: Show and manage authentication token
|
||||
|
||||
@ -790,14 +792,23 @@ class Osc(cmdln.Cmdln):
|
||||
|
||||
args = slash_split(args)
|
||||
|
||||
if opts.scm_token and opts.operation != 'workflow':
|
||||
msg = 'The --scm-token option requires a --operation=workflow option'
|
||||
raise oscerr.WrongOptions(msg)
|
||||
|
||||
apiurl = self.get_api_url()
|
||||
url_path = ['person', conf.get_apiurl_usr(apiurl), 'token']
|
||||
|
||||
if opts.create:
|
||||
if opts.operation == 'workflow' and not opts.scm_token:
|
||||
msg = 'The --operation=workflow option requires a --scm-token=<token> option'
|
||||
raise oscerr.WrongOptions(msg)
|
||||
print("Create a new token")
|
||||
query = {'cmd': 'create'}
|
||||
if opts.operation:
|
||||
query['operation'] = opts.operation
|
||||
if opts.scm_token:
|
||||
query['scm_token'] = opts.scm_token
|
||||
if len(args) > 1:
|
||||
query['project'] = args[0]
|
||||
query['package'] = args[1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user