enforce required credential fields at job start time rather than on save

this is necessary for credential plugins support so that you can (in two
requests):

1.  Save a Credential with _no_ input values defined
2.  Create/associate one (or more) CredentialInputSource records to the
    new Credential
This commit is contained in:
Ryan Petrello
2019-02-28 11:24:38 -05:00
committed by Jake McDermott
parent e2d474ddd2
commit 42f4956a7f
4 changed files with 52 additions and 34 deletions

View File

@@ -655,13 +655,7 @@ class CredentialInputField(JSONSchemaField):
)
errors[error.schema['id']] = [error.message]
inputs = model_instance.credential_type.inputs
defined_fields = model_instance.credential_type.defined_fields
for field in inputs.get('required', []):
if field in defined_fields and not value.get(field, None):
errors[field] = [_('required for %s') % (
model_instance.credential_type.name
)]
# `ssh_key_unlock` requirements are very specific and can't be
# represented without complicated JSON schema