endpoints.api.trigger: clarify token->write_token
This commit is contained in:
parent
3798c5f377
commit
0c3becd204
1 changed files with 7 additions and 6 deletions
|
@ -207,24 +207,25 @@ class BuildTriggerActivate(RepositoryParamResource):
|
||||||
# Update the config.
|
# Update the config.
|
||||||
new_config_dict = request.get_json()['config']
|
new_config_dict = request.get_json()['config']
|
||||||
|
|
||||||
token_name = 'Build Trigger: %s' % trigger.service.name
|
write_token_name = 'Build Trigger: %s' % trigger.service.name
|
||||||
token = model.create_delegate_token(namespace, repository, token_name,
|
write_token = model.create_delegate_token(namespace, repository, write_token_name,
|
||||||
'write')
|
'write')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
path = url_for('webhooks.build_trigger_webhook', trigger_uuid=trigger.uuid)
|
path = url_for('webhooks.build_trigger_webhook', trigger_uuid=trigger.uuid)
|
||||||
authed_url = _prepare_webhook_url(app.config['PREFERRED_URL_SCHEME'], '$token', token.code,
|
authed_url = _prepare_webhook_url(app.config['PREFERRED_URL_SCHEME'],
|
||||||
|
'$token', write_token.code,
|
||||||
app.config['SERVER_HOSTNAME'], path)
|
app.config['SERVER_HOSTNAME'], path)
|
||||||
|
|
||||||
final_config, trigger.private_key = handler.activate(trigger.uuid, authed_url,
|
final_config, trigger.private_key = handler.activate(trigger.uuid, authed_url,
|
||||||
trigger.auth_token, new_config_dict)
|
trigger.auth_token, new_config_dict)
|
||||||
except TriggerActivationException as exc:
|
except TriggerActivationException as exc:
|
||||||
token.delete_instance()
|
write_token.delete_instance()
|
||||||
raise request_error(message=exc.message)
|
raise request_error(message=exc.message)
|
||||||
|
|
||||||
# Save the updated config.
|
# Save the updated config.
|
||||||
trigger.config = json.dumps(final_config)
|
trigger.config = json.dumps(final_config)
|
||||||
trigger.write_token = token
|
trigger.write_token = write_token
|
||||||
trigger.save()
|
trigger.save()
|
||||||
|
|
||||||
# Log the trigger setup.
|
# Log the trigger setup.
|
||||||
|
|
Reference in a new issue