1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Correctly validate module name for modules with aliases (#29957)

* Correctly validate module name for modules with aliases

If a module has an alias (ie is a symlink) then we need to ensure that
DOCUMENTATION.module is set to the main name, not the aliased name

* formatting
This commit is contained in:
John R Barker 2017-09-12 13:30:49 +01:00 committed by GitHub
parent 1da7194534
commit bc2f4365b5

View file

@ -802,7 +802,14 @@ class ModuleValidator(Validator):
msg='Module deprecated, but DOCUMENTATION.deprecated is missing'
)
self._validate_docs_schema(doc, doc_schema(self.object_name.split('.')[0]), 'DOCUMENTATION', 305)
if os.path.islink(self.object_path):
# This module has an alias, which we can tell as it's a symlink
# Rather than checking for `module: $filename` we need to check against the true filename
self._validate_docs_schema(doc, doc_schema(os.readlink(self.object_path).split('.')[0]), 'DOCUMENTATION', 305)
else:
# This is the normal case
self._validate_docs_schema(doc, doc_schema(self.object_name.split('.')[0]), 'DOCUMENTATION', 305)
self._check_version_added(doc)
self._check_for_new_args(doc)