mirror of
https://github.com/ansible/awx.git
synced 2026-03-16 00:17:29 -02:30
Merge pull request #4596 from ryanpetrello/fix-cli-required-args
cli: fix a few bugs related to required OPTIONS Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -92,12 +92,14 @@ class ResourceOptionsParser(object):
|
||||
'field': int,
|
||||
'integer': int,
|
||||
'boolean': strtobool,
|
||||
'field': int, # foreign key
|
||||
}.get(param['type'], str),
|
||||
}
|
||||
meta_map = {
|
||||
'string': 'TEXT',
|
||||
'integer': 'INTEGER',
|
||||
'boolean': 'BOOLEAN',
|
||||
'field': 'ID', # foreign key
|
||||
}
|
||||
if param.get('choices', []):
|
||||
kwargs['choices'] = [c[0] for c in param['choices']]
|
||||
@@ -110,6 +112,20 @@ class ResourceOptionsParser(object):
|
||||
elif param['type'] in meta_map:
|
||||
kwargs['metavar'] = meta_map[param['type']]
|
||||
|
||||
if param['type'] == 'field':
|
||||
kwargs['help'] = 'the ID of the associated {}'.format(k)
|
||||
|
||||
# SPECIAL CUSTOM LOGIC GOES HERE :'(
|
||||
# There are certain requirements that aren't captured well by our
|
||||
# HTTP OPTIONS due to $reasons
|
||||
# This is where custom handling for those goes.
|
||||
if self.resource == 'users' and method == 'create' and k == 'password':
|
||||
kwargs['required'] = required = True
|
||||
if self.resource == 'ad_hoc_commands' and method == 'create' and k in ('inventory', 'credential'):
|
||||
kwargs['required'] = required = True
|
||||
if self.resource == 'job_templates' and method == 'create' and k in ('project', 'playbook'):
|
||||
kwargs['required'] = required = True
|
||||
|
||||
if required:
|
||||
required_group.add_argument(
|
||||
'--{}'.format(k),
|
||||
|
||||
Reference in New Issue
Block a user