|
| 1 | +# Kube-IDEA — Copilot Instructions |
| 2 | + |
| 3 | +## Stack |
| 4 | + |
| 5 | +- **Language**: Python ≥ 3.11 with full type annotations (`mypy --strict`). |
| 6 | +- **UI**: [Flet](https://flet.dev) (Flutter renderer). Use `ft.run()` — `ft.app()` is deprecated since 0.80. |
| 7 | +- **Dependencies**: managed with Poetry (`pyproject.toml` + `poetry.lock`). Do not edit `poetry.lock` manually. |
| 8 | +- **Linter / formatter**: `ruff` (rules E, F, I, N, W, UP). Never disable rules without a comment explaining why. |
| 9 | +- **Testing**: `pytest` under `tests/`. Async tests use `pytest-asyncio`. Target coverage ≥ 80 %. |
| 10 | + |
| 11 | +## Project layout |
| 12 | + |
| 13 | +``` |
| 14 | +src/kubeidea/ |
| 15 | + app.py # Flet bootstrap — ft.run(main) |
| 16 | + ui/ # All Flet views and navigation |
| 17 | + core/ # AppContext, business logic, use-cases |
| 18 | + kube/ # kubernetes-python API wrappers |
| 19 | + metrics/ # metrics-server / Prometheus adapters |
| 20 | + plugins/ # Plugin host and entry-point discovery |
| 21 | + security/ # RBAC inspector, SubjectAccessReview |
| 22 | + config/ # Settings persistence |
| 23 | + utils/ # Logging, telemetry helpers |
| 24 | +tests/ # Mirrors src/kubeidea/ structure |
| 25 | +``` |
| 26 | + |
| 27 | +See [docs/architecture.md](docs/architecture.md) for component boundaries. |
| 28 | + |
| 29 | +## Coding conventions |
| 30 | + |
| 31 | +- Views extend `ft.Column` or `ft.Container`; receive `page: ft.Page` in `__init__`. |
| 32 | +- Navigation index → view mapping lives in `app.py`; do not embed routing logic inside views. |
| 33 | +- `ft.Icon` takes the icon **as the first positional argument**, not `name=`. |
| 34 | +- All Kubernetes calls go through `kube/client.py` — never import `kubernetes` directly in UI code. |
| 35 | +- Secrets are never stored to disk; use the OS keyring (`keyring` lib) where persistence is required. |
| 36 | +- Telemetry is opt-in only; never collect data unless the user has explicitly enabled it in settings. |
| 37 | + |
| 38 | +## CI / build |
| 39 | + |
| 40 | +- `poetry run pytest` — must pass before any PR merge. |
| 41 | +- `poetry run ruff check src/ tests/` — zero warnings. |
| 42 | +- `poetry run mypy src/kubeidea/` — zero errors. |
| 43 | +- Desktop binaries are built with `flet build <target>` via the release workflow on `v*` tags. |
| 44 | +- Docs are deployed to `gh-pages` branch with `mkdocs gh-deploy --force`. |
| 45 | + |
| 46 | +## Security (DevSecOps) |
| 47 | + |
| 48 | +- All cluster actions must respect the user's RBAC via `SubjectAccessReview` — see `security/rbac.py`. |
| 49 | +- Never log kubeconfig tokens, credentials, or secret values. |
| 50 | +- Dependencies must stay pinned in `poetry.lock`; raise a PR to update them explicitly. |
0 commit comments