mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-22 06:28:53 +02: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:
@@ -771,9 +771,11 @@ class Osc(cmdln.Cmdln):
|
|||||||
@cmdln.option('-d', '--delete', metavar='TOKENID',
|
@cmdln.option('-d', '--delete', metavar='TOKENID',
|
||||||
help='Delete a token')
|
help='Delete a token')
|
||||||
@cmdln.option('-o', '--operation', metavar='OPERATION',
|
@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',
|
@cmdln.option('-t', '--trigger', metavar='TOKENSTRING',
|
||||||
help='Trigger the action of a token')
|
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):
|
def do_token(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Show and manage authentication token
|
"""${cmd_name}: Show and manage authentication token
|
||||||
|
|
||||||
@@ -790,14 +792,23 @@ class Osc(cmdln.Cmdln):
|
|||||||
|
|
||||||
args = slash_split(args)
|
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()
|
apiurl = self.get_api_url()
|
||||||
url_path = ['person', conf.get_apiurl_usr(apiurl), 'token']
|
url_path = ['person', conf.get_apiurl_usr(apiurl), 'token']
|
||||||
|
|
||||||
if opts.create:
|
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")
|
print("Create a new token")
|
||||||
query = {'cmd': 'create'}
|
query = {'cmd': 'create'}
|
||||||
if opts.operation:
|
if opts.operation:
|
||||||
query['operation'] = opts.operation
|
query['operation'] = opts.operation
|
||||||
|
if opts.scm_token:
|
||||||
|
query['scm_token'] = opts.scm_token
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
query['project'] = args[0]
|
query['project'] = args[0]
|
||||||
query['package'] = args[1]
|
query['package'] = args[1]
|
||||||
|
Reference in New Issue
Block a user