feat(cli): add --no-build flag to state push for state-only updates (#21374)

## Summary

Adds a `--no-build` flag to `coder state push` that updates the
Terraform state directly without triggering a workspace build.

## Use Case

This enables state-only migrations, such as migrating Kubernetes
resources from deprecated types (e.g., `kubernetes_config_map`) to
versioned types (e.g., `kubernetes_config_map_v1`):

```bash
coder state pull my-workspace > state.json
terraform init
terraform state rm -state=state.json kubernetes_config_map.example
terraform import -state=state.json kubernetes_config_map_v1.example default/example
coder state push --no-build my-workspace state.json
```

## Changes

- Add `PUT /api/v2/workspacebuilds/{id}/state` endpoint to update state
without triggering a build
- Add `UpdateWorkspaceBuildState` SDK method
- Add `--no-build`/`-n` flag to `coder state push`
- Add confirmation prompt (can be skipped with `--yes`/`-y`) since this
is a potentially dangerous operation
- Add test for `--no-build` functionality

Fixes #21336
This commit is contained in:
Kacper Sawicki
2026-01-12 15:16:59 +01:00
committed by GitHub
parent a581431bc8
commit 6ca70d3618
12 changed files with 315 additions and 0 deletions
+9
View File
@@ -5606,6 +5606,15 @@ export interface UpdateWorkspaceAutostartRequest {
readonly schedule?: string;
}
// From codersdk/workspacebuilds.go
/**
* UpdateWorkspaceBuildStateRequest is the request body for updating the
* provisioner state of a workspace build.
*/
export interface UpdateWorkspaceBuildStateRequest {
readonly state: string;
}
// From codersdk/workspaces.go
/**
* UpdateWorkspaceDormancy is a request to activate or make a workspace dormant.