Implement namespace scoping for /api/agents#1878
Conversation
Signed-off-by: Maaz Ghani <mghani@lululemon.com>
32a94d8 to
95c5b81
Compare
|
Verification performed so far: |
|
@claude please review as well. Edit: or not |
There was a problem hiding this comment.
Pull request overview
This PR adds namespace-scoped agent listing support by introducing a new /api/agents/{namespace} endpoint, wiring it into both the UI’s getAgents action and the Go API client, and adding handler tests to validate the filtering behavior.
Changes:
- Add
GET /api/agents/{namespace}route and handler to list Agents/AgentHarnesses restricted to a namespace (with namespace validation). - Update UI
getAgentsaction to optionally call the namespace-scoped endpoint. - Extend Go API client to support listing agents for a specific namespace and add handler test coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/app/actions/agents.ts | Add optional namespace parameter to getAgents() to call a namespace-scoped agents endpoint. |
| go/core/internal/httpserver/server.go | Register a new GET /api/agents/{namespace} route. |
| go/core/internal/httpserver/handlers/agents.go | Implement HandleListAgentsForNamespace with Kubernetes namespace validation and namespace-scoped listing. |
| go/core/internal/httpserver/handlers/agents_test.go | Add tests ensuring namespace-scoped listing filters both Agents and AgentHarnesses. |
| go/api/client/agent.go | Add a client method (and interface entry) for listing agents by namespace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7035655 to
b6ed0c8
Compare
|
Please ignore my force-pushes I forgot to sign the commit(s). |
Signed-off-by: Codex <codex@openai.com> Signed-off-by: Maaz Ghani <maazghani@gmail.com>
54ada34 to
0c54895
Compare
Signed-off-by: Maaz Ghani <maazghani@gmail.com>
EItanya
left a comment
There was a problem hiding this comment.
Hey there, I'm a little worried about using a path var here is a bit fragile, can we potentially use a query variable instead?
|
Thanks, makes sense. I used the path because was thinking of namespace as scope (like future RBAC support), not just a filter, and it matched the existing Happy to switch this to a query param if that’s preferred. |
Addresses #1812 and @EItanya's feedback to implement server side. If this PR lands, I have a draft of a potential UI implementation.
Adds
GET /api/agents/{namespace}to work likekubectl get agent -n kagent, and leavingGET /api/agentsaskubectl get agent -A.Re-use existing namespace validation pattern to return invalid namespaces as 400 bad request.
HandleListAgentsForNamespacehandler with tests/{namespace}inserver.goListAgentsto hit path-based/api/agents/${namespace}Ran e2e tests using kind-backed env successfully, and validated namespace-filtering works.