Files
computer-playbook/cli/administration/inventory/provision/role_resolver.py
T
kevinveenbirkenbachandClaude Opus 4.7 a080dc4f98 refactor(cli): inventory tools under administration/, drop role scaffolder + dead SSO indirection
Move:
- cli/build/inventory/full      -> cli/administration/inventory/devices
- cli/create/inventory          -> cli/administration/inventory/provision
- cli/create/credentials        -> cli/administration/inventory/credentials
- cli/encrypt/inventory         -> cli/administration/inventory/encrypt

Delete:
- cli/create/role + templates/roles/ (stale scaffolder)
- roles/web-app-baserow/templates/javascript.js.j2 + dead sso_warning snippet
- js_application_name across akaunting/baserow/opencloud/opentalk/taiga,
  javascript service disabled for baserow + taiga

Wire-through:
- argv lists in cli/deploy/{container,development}/* + 2 shell scripts
  now invoke 'infinito administration inventory provision'
- subprocess module names + docs (contributing/* + administration/deploy.md)
- discovery resolver test + folder-item-limit whitelist updated
- ruff fixes in devices/command.py (RET504 inline + Path.open over open)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 18:41:04 +02:00

54 lines
1.2 KiB
Python

from __future__ import annotations
import sys
from pathlib import Path
from .subprocess_runner import run_subprocess
def resolve_role_path(
application_id: str,
roles_dir: Path,
project_root: Path,
env: dict[str, str] | None,
) -> Path | None:
"""
Resolve role path by calling:
python -m cli.meta.roles.applications.role_name <app_id> -r <roles_dir>
The helper may print:
- bare folder name (e.g. web-app-nextcloud)
- relative path (e.g. roles/web-app-nextcloud)
- absolute path
"""
cmd = [
sys.executable,
"-m",
"cli.meta.roles.applications.role_name",
application_id,
"-r",
str(roles_dir),
]
result = run_subprocess(cmd, capture_output=True, env=env)
raw = (result.stdout or "").strip()
if not raw:
return None
printed = Path(raw)
if printed.is_absolute():
role_path = printed
else:
cand1 = roles_dir / printed
if cand1.exists():
role_path = cand1
else:
cand2 = project_root / printed
if cand2.exists():
role_path = cand2
else:
return None
return role_path if role_path.exists() else None