Merge pull request #4610 from ryanpetrello/cli-cleanup-injectors-language

fix a few minor CLI bugs

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-08-29 14:15:48 +00:00
committed by GitHub
3 changed files with 39 additions and 18 deletions

View File

@@ -0,0 +1,29 @@
# Generated by Django 2.2.4 on 2019-08-27 21:50
import awx.main.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0086_v360_workflow_approval'),
]
operations = [
migrations.AlterField(
model_name='credential',
name='inputs',
field=awx.main.fields.CredentialInputField(blank=True, default=dict, help_text='Enter inputs using either JSON or YAML syntax. Refer to the Ansible Tower documentation for example syntax.'),
),
migrations.AlterField(
model_name='credentialtype',
name='injectors',
field=awx.main.fields.CredentialTypeInjectorField(blank=True, default=dict, help_text='Enter injectors using either JSON or YAML syntax. Refer to the Ansible Tower documentation for example syntax.'),
),
migrations.AlterField(
model_name='credentialtype',
name='inputs',
field=awx.main.fields.CredentialTypeInputField(blank=True, default=dict, help_text='Enter inputs using either JSON or YAML syntax. Refer to the Ansible Tower documentation for example syntax.'),
),
]

View File

@@ -106,9 +106,8 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
inputs = CredentialInputField( inputs = CredentialInputField(
blank=True, blank=True,
default=dict, default=dict,
help_text=_('Enter inputs using either JSON or YAML syntax. Use the ' help_text=_('Enter inputs using either JSON or YAML syntax. '
'radio button to toggle between the two. Refer to the ' 'Refer to the Ansible Tower documentation for example syntax.')
'Ansible Tower documentation for example syntax.')
) )
admin_role = ImplicitRoleField( admin_role = ImplicitRoleField(
parent_role=[ parent_role=[
@@ -344,16 +343,14 @@ class CredentialType(CommonModelNameNotUnique):
inputs = CredentialTypeInputField( inputs = CredentialTypeInputField(
blank=True, blank=True,
default=dict, default=dict,
help_text=_('Enter inputs using either JSON or YAML syntax. Use the ' help_text=_('Enter inputs using either JSON or YAML syntax. '
'radio button to toggle between the two. Refer to the ' 'Refer to the Ansible Tower documentation for example syntax.')
'Ansible Tower documentation for example syntax.')
) )
injectors = CredentialTypeInjectorField( injectors = CredentialTypeInjectorField(
blank=True, blank=True,
default=dict, default=dict,
help_text=_('Enter injectors using either JSON or YAML syntax. Use the ' help_text=_('Enter injectors using either JSON or YAML syntax. '
'radio button to toggle between the two. Refer to the ' 'Refer to the Ansible Tower documentation for example syntax.')
'Ansible Tower documentation for example syntax.')
) )
@classmethod @classmethod

View File

@@ -59,15 +59,6 @@ class ResourceOptionsParser(object):
def build_query_arguments(self, method, http_method): def build_query_arguments(self, method, http_method):
required_group = None required_group = None
if filter(
lambda param: param.get('required', False) is True,
self.options.get(http_method, {}).values()
):
if method in self.parser.choices:
required_group = self.parser.choices[method].add_argument_group('required arguments')
# put the required group first (before the optional args group)
self.parser.choices[method]._action_groups.reverse()
for k, param in self.options.get(http_method, {}).items(): for k, param in self.options.get(http_method, {}).items():
required = ( required = (
method == 'create' and method == 'create' and
@@ -154,6 +145,10 @@ class ResourceOptionsParser(object):
kwargs['type'] = jsonstr kwargs['type'] = jsonstr
if required: if required:
if required_group is None:
required_group = self.parser.choices[method].add_argument_group('required arguments')
# put the required group first (before the optional args group)
self.parser.choices[method]._action_groups.reverse()
required_group.add_argument( required_group.add_argument(
'--{}'.format(k), '--{}'.format(k),
**kwargs **kwargs