summaryrefslogtreecommitdiff
path: root/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py')
-rw-r--r--test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py24
1 files changed, 16 insertions, 8 deletions
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 5ca248124c..42a2ada4af 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
@@ -9,6 +9,7 @@ __metaclass__ = type
import re
from distutils.version import StrictVersion
+from functools import partial
from voluptuous import ALLOW_EXTRA, PREVENT_EXTRA, All, Any, Invalid, Length, Required, Schema, Self, ValueInvalid
from ansible.module_utils.six import string_types
@@ -226,7 +227,7 @@ json_value = Schema(Any(
))
-def version_added(v):
+def version_added(v, error_code='version-added-invalid', accept_historical=False):
if 'version_added' in v:
version_added = v.get('version_added')
if isinstance(version_added, string_types):
@@ -234,6 +235,8 @@ def version_added(v):
# - or we have a float and we are in ansible/ansible, in which case we're
# also happy.
if v.get('version_added_collection') == 'ansible.builtin':
+ if version_added == 'historical' and accept_historical:
+ return v
try:
version = StrictVersion()
version.parse(version_added)
@@ -241,7 +244,7 @@ def version_added(v):
raise _add_ansible_error_code(
Invalid('version_added (%r) is not a valid ansible-base version: '
'%s' % (version_added, exc)),
- error_code='deprecation-either-date-or-version')
+ error_code=error_code)
else:
try:
version = SemanticVersion()
@@ -251,7 +254,7 @@ def version_added(v):
Invalid('version_added (%r) is not a valid collection version '
'(see specification at https://semver.org/): '
'%s' % (version_added, exc)),
- error_code='deprecation-either-date-or-version')
+ error_code=error_code)
elif 'version_added_collection' in v:
# Must have been manual intervention, since version_added_collection is only
# added automatically when version_added is present
@@ -304,7 +307,7 @@ def list_dict_option_schema(for_collection):
option_version_added = Schema(
All({
'suboptions': Any(None, *[{str_type: Self} for str_type in string_types]),
- }, version_added),
+ }, partial(version_added, error_code='option-invalid-version-added')),
extra=ALLOW_EXTRA
)
@@ -343,7 +346,7 @@ def return_schema(for_collection):
}
),
Schema(return_contains),
- Schema(version_added),
+ Schema(partial(version_added, error_code='option-invalid-version-added')),
),
Schema(type(None)),
)
@@ -371,7 +374,7 @@ def return_schema(for_collection):
}
),
Schema({any_string_types: return_contains}),
- Schema({any_string_types: version_added}),
+ Schema({any_string_types: partial(version_added, error_code='option-invalid-version-added')}),
),
Schema(type(None)),
)
@@ -460,8 +463,13 @@ def doc_schema(module_name, for_collection=False, deprecated_module=False):
doc_schema_dict.update(deprecation_required_scheme)
return Schema(
- doc_schema_dict,
- extra=PREVENT_EXTRA
+ All(
+ Schema(
+ doc_schema_dict,
+ extra=PREVENT_EXTRA
+ ),
+ partial(version_added, error_code='module-invalid-version-added', accept_historical=not for_collection),
+ )
)