Merge pull request #9682 from ryanpetrello/custom-cred-open-ssh-newline

fix a bug that improperly formats OpenSSH keys in custom credential types

cc @ghjm
see: #9361

Reviewed-by: Jake McDermott <yo@jakemcdermott.me>
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-03-24 20:07:08 +00:00 committed by GitHub
commit 41e2920211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -466,10 +466,14 @@ class CredentialType(CommonModelNameNotUnique):
if len(value):
namespace[field_name] = value
# default missing boolean fields to False
for field in self.inputs.get('fields', []):
# default missing boolean fields to False
if field['type'] == 'boolean' and field['id'] not in credential.inputs.keys():
namespace[field['id']] = safe_namespace[field['id']] = False
# make sure private keys end with a \n
if field.get('format') == 'ssh_private_key':
if field['id'] in namespace and not namespace[field['id']].endswith('\n'):
namespace[field['id']] += '\n'
file_tmpls = self.injectors.get('file', {})
# If any file templates are provided, render the files and update the