summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2021-09-02 17:03:24 -0400
committerGitHub <noreply@github.com>2021-09-02 14:03:24 -0700
commit12c4661bbb6759e96391a6bc46f654558836492c (patch)
treec961d44c91d0b574199a354e41ed501cd99c70b2
parent5bc16fcc15b1ff10b805893c60ded6c06b60a935 (diff)
downloadansible-12c4661bbb6759e96391a6bc46f654558836492c.tar.gz
Attributes compat (#75563) (#75621)
* 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)
-rw-r--r--changelogs/fragments/attributes_compat.yml2
-rw-r--r--lib/ansible/cli/doc.py9
-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.py1
4 files changed, 28 insertions, 2 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 ac1bf38a8d..e658f07bcd 100644
--- a/lib/ansible/cli/doc.py
+++ b/lib/ansible/cli/doc.py
@@ -71,6 +71,7 @@ class DocCLI(CLI):
# default ignore list for detailed views
IGNORE = ('module', 'docuri', 'version_added', 'short_description', 'now_date', 'plainexamples', 'returndocs', 'collection')
+ JSON_IGNORE = ('attributes',)
# Warning: If you add more elements here, you also need to add it to the docsite build (in the
# ansible-community/antsibull repo)
@@ -262,8 +263,13 @@ class DocCLI(CLI):
plugin_docs[plugin] = DocCLI._combine_plugin_doc(plugin, plugin_type, doc, plainexamples, returndocs, metadata)
if do_json:
+ for entry in plugin_docs.keys():
+ for forbid in DocCLI.JSON_IGNORE:
+ try:
+ del plugin_docs[entry]['doc'][forbid]
+ except (KeyError, TypeError):
+ pass
jdump(plugin_docs)
-
else:
# Some changes to how plain text docs are formatted
text = []
@@ -278,7 +284,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 42a2ada4af..50254f2d2b 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
@@ -448,6 +448,7 @@ def doc_schema(module_name, for_collection=False, deprecated_module=False):
'options': Any(None, *list_dict_option_schema(for_collection)),
'extends_documentation_fragment': Any(list_string_types, *string_types),
'version_added_collection': collection_name,
+ 'attributes': object,
}
if for_collection: