Fix metadata defaults

* Metadata defaults were not being set if only a few fields were missing.

* ansible-doc with no documentation and no status in metadata should
  return empty, just like if there was no documentation and no metadata
  at all.
pull/69337/head
Toshio Kuratomi 5 years ago
parent 6d8cfcf539
commit 049800c063

@ -0,0 +1,5 @@
bugfixes:
- Plugin Metadata is supposed to have default values. When the metadata was
missing entirely, we were properly setting the defaults. Fixed the metadata
parsing so that the defaults are also set when we were missing just a few
fields.

@ -67,9 +67,16 @@ def read_docstring(filename, verbose=True, ignore_errors=True):
if data['metadata']: if data['metadata']:
# remove version # remove version
for x in ('version', 'metadata_version'): for field in ('version', 'metadata_version'):
if x in data['metadata']: if field in data['metadata']:
del data['metadata'][x] del data['metadata'][field]
if 'supported_by' not in data['metadata']:
data['metadata']['supported_by'] = 'community'
if 'status' not in data['metadata']:
data['metadata']['status'] = ['preview']
else: else:
# Add default metadata # Add default metadata
data['metadata'] = {'supported_by': 'community', data['metadata'] = {'supported_by': 'community',

@ -85,8 +85,8 @@
register: result register: result
- assert: - assert:
that: that:
- 'result is failed' - 'result.stdout == ""'
- '"ERROR! module test_no_docs_no_status missing documentation (or could not parse documentation): test_no_docs_no_status did not contain a DOCUMENTATION attribute" in result.stderr' - 'result.stderr == ""'
- name: module with no documentation and non-iterable status in metadata - name: module with no documentation and non-iterable status in metadata
command: ansible-doc test_no_docs_non_iterable_status command: ansible-doc test_no_docs_non_iterable_status

Loading…
Cancel
Save