feat: add compose file discovery for scan mode
This commit is contained in:
parent
cd80dadf32
commit
3ab5c8d3fd
1 changed files with 28 additions and 0 deletions
28
dockervault/discovery.py
Normal file
28
dockervault/discovery.py
Normal 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)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue