From 852aa33101bd0340d045490624304f6597aebb2c Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 23 Apr 2015 18:14:26 -0400 Subject: [PATCH] endpoints.trigger: activate: ret private config --- endpoints/api/trigger.py | 6 +++++- endpoints/trigger.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/endpoints/api/trigger.py b/endpoints/api/trigger.py index d7d7a1c20..72a04fd0b 100644 --- a/endpoints/api/trigger.py +++ b/endpoints/api/trigger.py @@ -217,8 +217,12 @@ class BuildTriggerActivate(RepositoryParamResource): '$token', write_token.code, app.config['SERVER_HOSTNAME'], path) - final_config, trigger.private_key = handler.activate(trigger.uuid, authed_url, + final_config, private_config = handler.activate(trigger.uuid, authed_url, trigger.auth_token, new_config_dict) + + if 'private_key' in private_config: + trigger.private_key = private_config['private_key'] + except TriggerActivationException as exc: write_token.delete_instance() raise request_error(message=exc.message) diff --git a/endpoints/trigger.py b/endpoints/trigger.py index f6283d849..557bb53e6 100644 --- a/endpoints/trigger.py +++ b/endpoints/trigger.py @@ -107,7 +107,7 @@ class BuildTrigger(object): def activate(self, trigger_uuid, standard_webhook_url, auth_token, config): """ Activates the trigger for the service, with the given new configuration. - Returns new configuration that should be stored if successful. + Returns new public and private config that should be stored if successful. """ raise NotImplementedError @@ -216,7 +216,7 @@ class GithubBuildTrigger(BuildTrigger): msg = 'Unable to create webhook on repository: %s' % new_build_source raise TriggerActivationException(msg) - return config, private_key + return config, {'private_key': private_key} def deactivate(self, auth_token, config): gh_client = self._get_client(auth_token) @@ -688,7 +688,7 @@ class CustomBuildTrigger(BuildTrigger): 'value': standard_webhook_url, }, ] - return config, private_key + return config, {'private_key': private_key} def deactivate(self, auth_token, config): config.pop('credentials', None)