summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2021-09-02 17:04:40 -0400
committerGitHub <noreply@github.com>2021-09-02 14:04:40 -0700
commit19261a7bedc58ad75a5e1781c1c8b3ebdc582a63 (patch)
tree0ffa1d013207f4128c7dc791eba867ef43243bb0
parente926f5fe99da9e64381b82652427b2c1f8568b72 (diff)
downloadansible-19261a7bedc58ad75a5e1781c1c8b3ebdc582a63.tar.gz
Attributes compat (#75563) (#75622)
* Attributes compat (#75563) * ignore 'attributes' for json dump let existing overrides display, wont be full info but still pertinent info though user will have to check newer versions (cherry picked from commit 463cf9fe244430249701509fc3ee7636a18afc44) (cherry picked from commit 93cc74ba13c28785d8e4b62adc8eb62f42860efb) * Update test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
-rw-r--r--changelogs/fragments/attributes_compat.yml2
-rw-r--r--lib/ansible/cli/doc.py10
-rw-r--r--lib/ansible/plugins/doc_fragments/action_common_attributes.py18
-rw-r--r--test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py3
4 files changed, 30 insertions, 3 deletions
diff --git a/changelogs/fragments/attributes_compat.yml b/changelogs/fragments/attributes_compat.yml
new file mode 100644
index 0000000000..74dabd3ef1
--- /dev/null
+++ b/changelogs/fragments/attributes_compat.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - make previous versions compatible we new attributres w/o implementing them.
diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py
index 72b6e7c409..cebaf270e7 100644
--- a/lib/ansible/cli/doc.py
+++ b/lib/ansible/cli/doc.py
@@ -52,6 +52,7 @@ class DocCLI(CLI):
# default ignore list for detailed views
IGNORE = ('module', 'docuri', 'version_added', 'short_description', 'now_date', 'plainexamples', 'returndocs')
+ JSON_IGNORE = ('attributes',)
def __init__(self, args):
@@ -214,13 +215,19 @@ class DocCLI(CLI):
if do_json:
# Some changes to how json docs are formatted
for plugin, doc_data in plugin_docs.items():
+
+ for forbid in DocCLI.JSON_IGNORE:
+ try:
+ del plugin_docs[plugin]['doc'][forbid]
+ except (KeyError, TypeError):
+ pass
+
try:
doc_data['return'] = yaml.load(doc_data['return'])
except Exception:
pass
jdump(plugin_docs)
-
else:
# Some changes to how plain text docs are formatted
text = []
@@ -233,7 +240,6 @@ class DocCLI(CLI):
if text:
DocCLI.pager(''.join(text))
-
return 0
@staticmethod
diff --git a/lib/ansible/plugins/doc_fragments/action_common_attributes.py b/lib/ansible/plugins/doc_fragments/action_common_attributes.py
new file mode 100644
index 0000000000..ea8fa7c9c6
--- /dev/null
+++ b/lib/ansible/plugins/doc_fragments/action_common_attributes.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+# Copyright: Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+
+# NOTE: this file is here to allow modules using the new attributes feature to
+# work w/o errors in this version of ansible, it does NOT provide the full
+# attributes feature, just a shim to avoid the fragment not being found.
+
+class ModuleDocFragment(object):
+
+ # Standard documentation fragment
+ DOCUMENTATION = r'''
+options: {}
+'''
diff --git a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py
index 2fe1c8fdb3..aa3fabb831 100644
--- a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py
+++ b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py
@@ -196,7 +196,8 @@ def doc_schema(module_name, version_added=True):
'requirements': list_string_types,
'todo': Any(None, list_string_types, *string_types),
'options': Any(None, *list_dict_option_schema),
- 'extends_documentation_fragment': Any(list_string_types, *string_types)
+ 'extends_documentation_fragment': Any(list_string_types, *string_types),
+ 'attributes': object,
}
if version_added: