feat: add compose file discovery for scan mode

This commit is contained in:
Eddie Nielsen 2026-03-23 15:24:18 +00:00
parent cd80dadf32
commit 3ab5c8d3fd

28
dockervault/discovery.py Normal file
View file

@ -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)