Skip to content

Commit

Permalink
Include powershell modules in the finder code. (#307)
Browse files Browse the repository at this point in the history
* Include powershell modules in the finder code.

No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner authored Nov 12, 2024
1 parent 44aa2b4 commit 7d66cd1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion galaxy_importer/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _find_plugins(self, content_type, content_dir):
"""Find all python files anywhere inside content_dir."""
for path, _, files in os.walk(content_dir):
for file in files:
if not file.endswith(".py") or file == "__init__.py":
if not file.endswith((".py", ".ps1")) or file == "__init__.py":
continue
file_path = os.path.join(path, file)
rel_path = os.path.relpath(file_path, self.path)
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,34 @@ def test_find_playbooks(self):
assert contents[0].content_type.name == "PLAYBOOK"
assert contents[0].path == "playbooks/play1.yml"

def test_find_powershell_modules(self):
ps_fn = os.path.join(self.module_dir, "foobar.ps1")
yml_fn = os.path.join(self.module_dir, "foobar.yaml")

docstring = {
"DOCUMENTATION": {
"module": "foobar",
"short_description": "",
"description": [],
"options": {},
}
}

# docs come from the yaml file so the
# powershell file content is irrelevant
with open(ps_fn, "w") as f:
f.write("\n")

with open(yml_fn, "w") as f:
yaml.dump(docstring, f)

contents = list(ContentFinder().find_contents(self.temp_dir))
assert len(contents) == 1
assert contents[0].path == "plugins/modules/foobar.ps1"
assert contents[0].content_type.name == "MODULE"
assert contents[0].content_type.value == "module"
assert contents[0].content_type.category.name == "MODULE"


@pytest.fixture
def walker_dir(tmp_path):
Expand Down

0 comments on commit 7d66cd1

Please sign in to comment.