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']) field['label'] = _(field['label'])
if 'help_text' in field: if 'help_text' in field:
field['help_text'] = _(field['help_text']) field['help_text'] = _(field['help_text'])
if field['type'] == 'become_method':
field['type'] = 'string'
return value return value
def filter_field_metadata(self, fields, method): def filter_field_metadata(self, fields, method):

View File

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

View File

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