mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
Added basic equivalent to PowerShell modules (#44705)
* Added basic equivalent to PowerShell modules * changes based on latest review * Added tests * ignore sanity test due to how tests are set up * Changes to work with PSCore * Added documentation and change updated more modules * Add some speed optimisations to AddType * fix some issues in the doc changes * doc changes
This commit is contained in:
parent
74619c2036
commit
501acae5ab
17 changed files with 3644 additions and 314 deletions
|
@ -702,6 +702,7 @@ class ModuleValidator(Validator):
|
|||
# check "shape" of each module name
|
||||
|
||||
module_requires = r'(?im)^#\s*requires\s+\-module(?:s?)\s*(Ansible\.ModuleUtils\..+)'
|
||||
csharp_requires = r'(?im)^#\s*ansiblerequires\s+\-csharputil\s*(Ansible\..+)'
|
||||
found_requires = False
|
||||
|
||||
for req_stmt in re.finditer(module_requires, self.text):
|
||||
|
@ -725,12 +726,33 @@ class ModuleValidator(Validator):
|
|||
msg='Module #Requires should not end in .psm1: "%s"' % module_name
|
||||
)
|
||||
|
||||
for req_stmt in re.finditer(csharp_requires, self.text):
|
||||
found_requires = True
|
||||
# this will bomb on dictionary format - "don't do that"
|
||||
module_list = [x.strip() for x in req_stmt.group(1).split(',')]
|
||||
if len(module_list) > 1:
|
||||
self.reporter.error(
|
||||
path=self.object_path,
|
||||
code=210,
|
||||
msg='Ansible C# util requirements do not support multiple utils per statement: "%s"' % req_stmt.group(0)
|
||||
)
|
||||
continue
|
||||
|
||||
module_name = module_list[0]
|
||||
|
||||
if module_name.lower().endswith('.cs'):
|
||||
self.reporter.error(
|
||||
path=self.object_path,
|
||||
code=211,
|
||||
msg='Module #AnsibleRequires -CSharpUtil should not end in .cs: "%s"' % module_name
|
||||
)
|
||||
|
||||
# also accept the legacy #POWERSHELL_COMMON replacer signal
|
||||
if not found_requires and REPLACER_WINDOWS not in self.text:
|
||||
self.reporter.error(
|
||||
path=self.object_path,
|
||||
code=207,
|
||||
msg='No Ansible.ModuleUtils module requirements/imports found'
|
||||
msg='No Ansible.ModuleUtils or C# Ansible util requirements/imports found'
|
||||
)
|
||||
|
||||
def _find_ps_docs_py_file(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue