diff --git a/changelogs/fragments/fix_module_schema.yml b/changelogs/fragments/fix_module_schema.yml new file mode 100644 index 00000000000..11966226f7e --- /dev/null +++ b/changelogs/fragments/fix_module_schema.yml @@ -0,0 +1,2 @@ +bugfixes: + - schema validation now uses dynamic range of versions for valid deprecation entries vs hardcoded out of date list. 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 d13831b5f6f..b335a5da95b 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 @@ -15,6 +15,7 @@ from voluptuous import ALLOW_EXTRA, PREVENT_EXTRA, All, Any, Invalid, Length, Re from ansible.module_utils.six import string_types from ansible.module_utils.common.collections import is_iterable from ansible.utils.version import SemanticVersion +from ansible.release import __version__ from .utils import parse_isodate @@ -59,6 +60,12 @@ def collection_name(v, error_code=None): return v +def deprecation_versions(): + """Create a list of valid version for deprecation entries, current+4""" + major, minor = [int(version) for version in __version__.split('.')[0:2]] + return Any(*['{0}.{1}'.format(major, minor + increment) for increment in range(0, 5)]) + + def version(for_collection=False): if for_collection: # We do not accept floats for versions in collections @@ -446,11 +453,7 @@ def deprecation_schema(for_collection): } else: version_schema = { - # Only list branches that are deprecated or may have docs stubs in - # Deprecation cycle changed at 2.4 (though not retroactively) - # 2.3 -> removed_in: "2.5" + n for docs stub - # 2.4 -> removed_in: "2.8" + n for docs stub - Required('removed_in'): Any("2.12", "2.13", "2.14", "2.15", "2.16"), + Required('removed_in'): deprecation_versions(), } version_schema.update(main_fields)