mirror of
https://github.com/quay/quay.git
synced 2025-07-30 07:43:13 +03:00
Handle generated ssh keypairs in build triggers as str (#503)
The keys are either part of a dict being serialized into json with json.dumps to pass as a requests' body, or passed directly to the client(e.g github). In both cases, the value needs to be a str.
This commit is contained in:
committed by
GitHub
parent
01a61a7d23
commit
a96fcabd03
@ -310,12 +310,12 @@ class BitbucketBuildTrigger(BuildTriggerHandler):
|
||||
# Add a deploy key to the repository.
|
||||
public_key, private_key = generate_ssh_keypair()
|
||||
config["credentials"] = [
|
||||
{"name": "SSH Public Key", "value": public_key,},
|
||||
{"name": "SSH Public Key", "value": public_key.decode("ascii"),},
|
||||
]
|
||||
|
||||
repository = self._get_repository_client()
|
||||
(result, created_deploykey, err_msg) = repository.deploykeys().create(
|
||||
app.config["REGISTRY_TITLE"] + " webhook key", public_key
|
||||
app.config["REGISTRY_TITLE"] + " webhook key", public_key.decode("ascii")
|
||||
)
|
||||
|
||||
if not result:
|
||||
@ -337,7 +337,7 @@ class BitbucketBuildTrigger(BuildTriggerHandler):
|
||||
|
||||
config["webhook_id"] = created_webhook["uuid"]
|
||||
self.config = config
|
||||
return config, {"private_key": private_key}
|
||||
return config, {"private_key": private_key.decode("ascii")}
|
||||
|
||||
def deactivate(self):
|
||||
config = self.config
|
||||
|
@ -194,11 +194,11 @@ class CustomBuildTrigger(BuildTriggerHandler):
|
||||
config = self.config
|
||||
public_key, private_key = generate_ssh_keypair()
|
||||
config["credentials"] = [
|
||||
{"name": "SSH Public Key", "value": public_key,},
|
||||
{"name": "SSH Public Key", "value": public_key.decode("ascii"),},
|
||||
{"name": "Webhook Endpoint URL", "value": standard_webhook_url,},
|
||||
]
|
||||
self.config = config
|
||||
return config, {"private_key": private_key}
|
||||
return config, {"private_key": private_key.decode("ascii")}
|
||||
|
||||
def deactivate(self):
|
||||
config = self.config
|
||||
|
@ -199,11 +199,13 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
||||
# Add a deploy key to the GitHub repository.
|
||||
public_key, private_key = generate_ssh_keypair()
|
||||
config["credentials"] = [
|
||||
{"name": "SSH Public Key", "value": public_key,},
|
||||
{"name": "SSH Public Key", "value": public_key.decode("ascii"),},
|
||||
]
|
||||
|
||||
try:
|
||||
deploy_key = gh_repo.create_key("%s Builder" % app.config["REGISTRY_TITLE"], public_key)
|
||||
deploy_key = gh_repo.create_key(
|
||||
"%s Builder" % app.config["REGISTRY_TITLE"], public_key.decode("ascii")
|
||||
)
|
||||
config["deploy_key_id"] = deploy_key.id
|
||||
except GithubException as ghe:
|
||||
default_msg = "Unable to add deploy key to repository: %s" % new_build_source
|
||||
@ -225,7 +227,7 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
||||
msg = GithubBuildTrigger._get_error_message(ghe, default_msg)
|
||||
raise TriggerActivationException(msg)
|
||||
|
||||
return config, {"private_key": private_key}
|
||||
return config, {"private_key": private_key.decode("ascii")}
|
||||
|
||||
@_catch_ssl_errors
|
||||
def deactivate(self):
|
||||
|
@ -227,7 +227,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
||||
# Add a deploy key to the repository.
|
||||
public_key, private_key = generate_ssh_keypair()
|
||||
config["credentials"] = [
|
||||
{"name": "SSH Public Key", "value": public_key,},
|
||||
{"name": "SSH Public Key", "value": public_key.decode("ascii"),},
|
||||
]
|
||||
|
||||
key = gl_project.keys.create(
|
||||
@ -259,7 +259,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
||||
|
||||
config["hook_id"] = hook.get_id()
|
||||
self.config = config
|
||||
return config, {"private_key": private_key}
|
||||
return config, {"private_key": private_key.decode("ascii")}
|
||||
|
||||
def deactivate(self):
|
||||
config = self.config
|
||||
|
Reference in New Issue
Block a user