endpoints.trigger: activate: ret private config

This commit is contained in:
Jimmy Zelinskie 2015-04-23 18:14:26 -04:00
parent 2a13eade80
commit 852aa33101
2 changed files with 8 additions and 4 deletions

View file

@ -217,8 +217,12 @@ class BuildTriggerActivate(RepositoryParamResource):
'$token', write_token.code, '$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, private_config = handler.activate(trigger.uuid, authed_url,
trigger.auth_token, new_config_dict) trigger.auth_token, new_config_dict)
if 'private_key' in private_config:
trigger.private_key = private_config['private_key']
except TriggerActivationException as exc: except TriggerActivationException as exc:
write_token.delete_instance() write_token.delete_instance()
raise request_error(message=exc.message) raise request_error(message=exc.message)

View file

@ -107,7 +107,7 @@ class BuildTrigger(object):
def activate(self, trigger_uuid, standard_webhook_url, auth_token, config): def activate(self, trigger_uuid, standard_webhook_url, auth_token, config):
""" """
Activates the trigger for the service, with the given new configuration. 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 raise NotImplementedError
@ -216,7 +216,7 @@ class GithubBuildTrigger(BuildTrigger):
msg = 'Unable to create webhook on repository: %s' % new_build_source msg = 'Unable to create webhook on repository: %s' % new_build_source
raise TriggerActivationException(msg) raise TriggerActivationException(msg)
return config, private_key return config, {'private_key': private_key}
def deactivate(self, auth_token, config): def deactivate(self, auth_token, config):
gh_client = self._get_client(auth_token) gh_client = self._get_client(auth_token)
@ -688,7 +688,7 @@ class CustomBuildTrigger(BuildTrigger):
'value': standard_webhook_url, 'value': standard_webhook_url,
}, },
] ]
return config, private_key return config, {'private_key': private_key}
def deactivate(self, auth_token, config): def deactivate(self, auth_token, config):
config.pop('credentials', None) config.pop('credentials', None)