diff --git a/dockervault/discovery.py b/dockervault/discovery.py new file mode 100644 index 0000000..65893c8 --- /dev/null +++ b/dockervault/discovery.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from pathlib import Path + +COMPOSE_FILENAMES = ( + "docker-compose.yml", + "docker-compose.yaml", + "compose.yml", + "compose.yaml", +) + + +def find_compose_files(root: str | Path) -> list[Path]: + root_path = Path(root).resolve() + + if not root_path.exists(): + raise FileNotFoundError(f"Scan root not found: {root_path}") + + if not root_path.is_dir(): + raise NotADirectoryError(f"Scan root is not a directory: {root_path}") + + found: list[Path] = [] + + for path in root_path.rglob("*"): + if path.is_file() and path.name in COMPOSE_FILENAMES: + found.append(path) + + return sorted(found)