generic trigger credentials
This commit is contained in:
parent
cfcd636cc0
commit
07b730c7ad
6 changed files with 66 additions and 45 deletions
|
@ -188,10 +188,16 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
raise TriggerActivationException(msg)
|
||||
|
||||
# Add a deploy key to the GitHub repository.
|
||||
public_key, private_key = generate_ssh_keypair()
|
||||
config['credentials'] = [
|
||||
{
|
||||
'name': 'SSH Public Key',
|
||||
'value': public_key,
|
||||
},
|
||||
]
|
||||
try:
|
||||
config['public_key'], private_key = generate_ssh_keypair()
|
||||
deploy_key = gh_repo.create_key('%s Builder' % app.config['REGISTRY_TITLE'],
|
||||
config['public_key'])
|
||||
public_key)
|
||||
config['deploy_key_id'] = deploy_key.id
|
||||
except GithubException:
|
||||
msg = 'Unable to add deploy key to repository: %s' % new_build_source
|
||||
|
@ -642,7 +648,7 @@ class CustomBuildTrigger(BuildTrigger):
|
|||
return 'custom-git'
|
||||
|
||||
def is_active(self, config):
|
||||
return 'public_key' in config
|
||||
return config.has_key('credentials')
|
||||
|
||||
def _metadata_from_payload(self, payload):
|
||||
try:
|
||||
|
@ -673,12 +679,21 @@ class CustomBuildTrigger(BuildTrigger):
|
|||
return dockerfile_id, tags, build_name, trigger.config['subdir'], metadata
|
||||
|
||||
def activate(self, trigger_uuid, standard_webhook_url, auth_token, config):
|
||||
config['webhook_url'] = standard_webhook_url
|
||||
config['public_key'], private_key = generate_ssh_keypair()
|
||||
public_key, private_key = generate_ssh_keypair()
|
||||
config['credentials'] = [
|
||||
{
|
||||
'name': 'SSH Public Key',
|
||||
'value': public_key,
|
||||
},
|
||||
{
|
||||
'name': 'Webhook Endpoint URL',
|
||||
'value': standard_webhook_url,
|
||||
},
|
||||
]
|
||||
return config, private_key
|
||||
|
||||
def deactivate(self, auth_token, config):
|
||||
config.pop('public_key', None)
|
||||
config.pop('credentials', None)
|
||||
return config
|
||||
|
||||
def manual_start(self, trigger, run_parameters=None):
|
||||
|
|
Reference in a new issue