From a107a17bc9593fc5bc489fa5ef0f98d17d1c7107 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 27 Aug 2019 17:31:26 -0400 Subject: [PATCH] fix a few minor CLI bugs see: https://github.com/ansible/awx/issues/4608 --- ...60_update_credential_injector_help_text.py | 29 +++++++++++++++++++ awx/main/models/credential/__init__.py | 15 ++++------ awxkit/awxkit/cli/options.py | 13 +++------ 3 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 awx/main/migrations/0087_v360_update_credential_injector_help_text.py diff --git a/awx/main/migrations/0087_v360_update_credential_injector_help_text.py b/awx/main/migrations/0087_v360_update_credential_injector_help_text.py new file mode 100644 index 0000000000..6f30daa4ad --- /dev/null +++ b/awx/main/migrations/0087_v360_update_credential_injector_help_text.py @@ -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.'), + ), + ] diff --git a/awx/main/models/credential/__init__.py b/awx/main/models/credential/__init__.py index d34cac27e3..5873e50a55 100644 --- a/awx/main/models/credential/__init__.py +++ b/awx/main/models/credential/__init__.py @@ -106,9 +106,8 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin): inputs = CredentialInputField( blank=True, default=dict, - help_text=_('Enter inputs using either JSON or YAML syntax. Use the ' - 'radio button to toggle between the two. Refer to the ' - 'Ansible Tower documentation for example syntax.') + help_text=_('Enter inputs using either JSON or YAML syntax. ' + 'Refer to the Ansible Tower documentation for example syntax.') ) admin_role = ImplicitRoleField( parent_role=[ @@ -344,16 +343,14 @@ class CredentialType(CommonModelNameNotUnique): inputs = CredentialTypeInputField( blank=True, default=dict, - help_text=_('Enter inputs using either JSON or YAML syntax. Use the ' - 'radio button to toggle between the two. Refer to the ' - 'Ansible Tower documentation for example syntax.') + help_text=_('Enter inputs using either JSON or YAML syntax. ' + 'Refer to the Ansible Tower documentation for example syntax.') ) injectors = CredentialTypeInjectorField( blank=True, default=dict, - help_text=_('Enter injectors using either JSON or YAML syntax. Use the ' - 'radio button to toggle between the two. Refer to the ' - 'Ansible Tower documentation for example syntax.') + help_text=_('Enter injectors using either JSON or YAML syntax. ' + 'Refer to the Ansible Tower documentation for example syntax.') ) @classmethod diff --git a/awxkit/awxkit/cli/options.py b/awxkit/awxkit/cli/options.py index 17b8a93c44..9ea1f6477d 100644 --- a/awxkit/awxkit/cli/options.py +++ b/awxkit/awxkit/cli/options.py @@ -59,15 +59,6 @@ class ResourceOptionsParser(object): def build_query_arguments(self, method, http_method): 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(): required = ( method == 'create' and @@ -154,6 +145,10 @@ class ResourceOptionsParser(object): kwargs['type'] = jsonstr 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( '--{}'.format(k), **kwargs