Skip to content

Add environment status API and CLI command#57

Open
dive2tech wants to merge 1 commit intoAffineFoundation:mainfrom
dive2tech:feature-env-status-cli
Open

Add environment status API and CLI command#57
dive2tech wants to merge 1 commit intoAffineFoundation:mainfrom
dive2tech:feature-env-status-cli

Conversation

@dive2tech
Copy link

Summary

  • Add public API helpers to inspect active environments and multi-instance pools.
  • Introduce afs status CLI command for human-readable and JSON status output.
  • Include tests for API helpers and CLI behavior, including the tabulate fallback.

Implementation details

  • affinetes.api:
    • get_environment_status(env_id, include_stats=True): returns JSON-serializable status for a single environment, including readiness and optional pool stats.
    • get_all_environment_statuses(include_stats=True): aggregates status for all active environments from the global registry.
  • affinetes.cli:
    • New afs status [NAME] [--json] [--verbose] command in cli/main.py.
    • Implementation in cli/commands.py:
      • Uses the new API helpers.
      • Supports table output via tabulate if available, otherwise a manual ASCII table fallback.
      • --json outputs raw JSON.
      • --verbose prints per-instance host/port/request counts for pools.
  • Tests:
    • tests/test_api_status.py: unit tests for the new API helpers (single env, pools, include_stats flag, aggregation).
    • tests/test_cli_status.py: tests CLI behavior including no envs, missing env name, JSON output, table fallback, and verbose instance details.

Test plan

  • Unit tests:
    • pytest tests/test_api_status.py tests/test_cli_status.py
  • Manual tests:
    • Start an environment:
      • afs run <image> --name test-env
    • Verify CLI:
      • afs status
      • afs status --json
      • afs status --verbose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant