from __future__ import annotations

from rich.console import Console
from rich.table import Table

from armorer.monitoring.ebpf import ebpf_capabilities, ebpf_plan


console = Console()


def ebpf_status_impl() -> None:
    payload = ebpf_capabilities()
    table = Table(title="eBPF Capabilities")
    table.add_column("Key")
    table.add_column("Value")
    for key in (
        "supported",
        "platform",
        "inside_container",
        "bpffs_available",
        "tracing_fs_available",
        "docker_socket_available",
        "recommended_mode",
    ):
        table.add_row(key, str(payload.get(key)))
    console.print(table)
    for note in payload.get("notes", []):
        console.print(f"- {note}")


def ebpf_plan_impl() -> None:
    payload = ebpf_plan()
    table = Table(title="eBPF Rollout Plan")
    table.add_column("Phase")
    table.add_column("Focus")
    table.add_column("Status")
    for phase in payload.get("phases", []):
        table.add_row(
            str(phase.get("name") or ""),
            str(phase.get("focus") or ""),
            str(phase.get("status") or ""),
        )
    console.print(table)
