mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-16 07:48:38 -05:00
clarify valid CredentialType field types
almost all of our current credential values are strings, but under the v1 Credential model, `authorize` is boolean additionally, if a field is specified with no type, fall back to `string` as a default (this is almost always what people creating custom types will want) see: #6406
This commit is contained in:
+13
-1
@@ -529,7 +529,7 @@ class CredentialTypeInputField(JSONSchemaField):
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'type': {'enum': ['string', 'number']},
|
||||
'type': {'enum': ['string', 'boolean']},
|
||||
'format': {'enum': ['ssh_private_key']},
|
||||
'choices': {
|
||||
'type': 'array',
|
||||
@@ -578,6 +578,18 @@ class CredentialTypeInputField(JSONSchemaField):
|
||||
)
|
||||
ids[id_] = True
|
||||
|
||||
if 'type' not in field:
|
||||
# If no type is specified, default to string
|
||||
field['type'] = 'string'
|
||||
|
||||
for key in ('choices', 'multiline', 'format'):
|
||||
if key in field and field['type'] != 'string':
|
||||
raise django_exceptions.ValidationError(
|
||||
_('%s not allowed for %s type (%s)' % (key, field['type'], field['id'])),
|
||||
code='invalid',
|
||||
params={'value': value},
|
||||
)
|
||||
|
||||
|
||||
|
||||
class CredentialTypeInjectorField(JSONSchemaField):
|
||||
|
||||
Reference in New Issue
Block a user