feat(cli): add coder task pause command#22012
Conversation
Add a new CLI command to pause a running task. The command accepts a task identifier (UUID, name, or owner/name format) and triggers a workspace build transition to stop the task. Features: - Interactive confirmation prompt with --yes flag to bypass - Build progress streaming when a workspace build is returned - Supports task resolution by UUID, name, or owner/name Includes unit tests with mock HTTP server covering happy paths, error handling, prompt confirmation/decline, and an integration test in the full task lifecycle sequence. Closes coder/internal#1263
cf23517 to
a6138a8
Compare
a6138a8 to
a742b6e
Compare
SasSwart
left a comment
There was a problem hiding this comment.
Thanks! Only two questions and a couple nits.
| return err | ||
| } | ||
|
|
||
| task, err := client.TaskByIdentifier(ctx, inv.Args[0]) |
There was a problem hiding this comment.
The endpoint already fetches the task based on the name/id provided in its middleware. Do we need to fetch it here in the CLI? We're incurring an additional round trip through HTTP and SQL.
Looks like we mostly fetch it to determine its owner for display purposes and then to pass back into the endpoint.
Would it be better to require the user to provide the owner name/id if they're trying to delete a task for a different user?
There was a problem hiding this comment.
We can do what you're suggesting although it'd require updating the client helper PauseTask defined in codersdk/aitasks.go from user string, id uuid.UUID to user, idOrName string
- Remove punctuation from example descriptions - Remove dead else branch for nil WorkspaceBuild (never nil on success) - Regenerate golden file and CLI docs
Documentation CheckUpdates Needed
The auto-generated CLI reference documentation ( Suggested addition between - [task pause](../reference/cli/task_pause.md) - Pause a task
Automated review via Coder Tasks |
Add a test case (OtherUserTask) that verifies an admin can pause a task owned by another user using the "owner/name" identifier format. Add a corresponding CLI example demonstrating this usage.
Summary
Add a new
coder task pauseCLI command that pauses a running task by triggering a workspace build transition to stop.Features
owner/nameformatcoder task pause alice/my-task)--yesflag to bypassTesting
Integration tests with a real coderd instance and echo provisioner (4 cases):
--yes, verifies output and server-side task statusowner/nameidentifierCloses coder/internal#1263 (Closes COCO-2)
Generated by Coder Mux