1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Removed the special-case logic for maintaining the schema of the become_method field

related #2630

Signed-off-by: Jeff Bradberry <jeff.bradberry@gmail.com>
This commit is contained in:
Jeff Bradberry 2019-01-29 14:06:26 -05:00
parent 0ecd6542bf
commit 6e1deed79e
3 changed files with 3 additions and 15 deletions

View File

@ -2496,8 +2496,6 @@ class CredentialTypeSerializer(BaseSerializer):
field['label'] = _(field['label'])
if 'help_text' in field:
field['help_text'] = _(field['help_text'])
if field['type'] == 'become_method':
field['type'] = 'string'
return value
def filter_field_metadata(self, fields, method):

View File

@ -510,8 +510,6 @@ class CredentialInputField(JSONSchemaField):
properties = {}
for field in model_instance.credential_type.inputs.get('fields', []):
field = field.copy()
if field['type'] == 'become_method':
field['type'] = 'string'
properties[field['id']] = field
if field.get('choices', []):
field['enum'] = list(field['choices'])[:]
@ -655,7 +653,7 @@ class CredentialTypeInputField(JSONSchemaField):
'items': {
'type': 'object',
'properties': {
'type': {'enum': ['string', 'boolean', 'become_method']},
'type': {'enum': ['string', 'boolean']},
'format': {'enum': ['ssh_private_key']},
'choices': {
'type': 'array',
@ -716,14 +714,6 @@ class CredentialTypeInputField(JSONSchemaField):
# If no type is specified, default to string
field['type'] = 'string'
if field['type'] == 'become_method':
if not model_instance.managed_by_tower:
raise django_exceptions.ValidationError(
_('become_method is a reserved type name'),
code='invalid',
params={'value': value},
)
for key in ('choices', 'multiline', 'format', 'secret',):
if key in field and field['type'] != 'string':
raise django_exceptions.ValidationError(

View File

@ -537,7 +537,7 @@ class CredentialType(CommonModelNameNotUnique):
if field['id'] == field_id:
if 'choices' in field:
return field['choices'][0]
return {'string': '', 'boolean': False, 'become_method': ''}[field['type']]
return {'string': '', 'boolean': False}[field['type']]
@classmethod
def default(cls, f):
@ -734,7 +734,7 @@ def ssh(cls):
}, {
'id': 'become_method',
'label': ugettext_noop('Privilege Escalation Method'),
'type': 'become_method',
'type': 'string',
'help_text': ugettext_noop('Specify a method for "become" operations. This is '
'equivalent to specifying the --become-method '
'Ansible parameter.')