From 2296da95a2d3a0f34f73ad9e5e5ff235f957e173 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 20 Apr 2021 10:02:39 -0400 Subject: [PATCH] fix module schema (#74295) * fix module schema not out of date hardcoded list anymore, uses 'current + 4' to set valid deprecation targets Co-authored-by: Matt Clay --- changelogs/fragments/fix_module_schema.yml | 2 ++ .../validate-modules/validate_modules/schema.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/fix_module_schema.yml 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)