Skip to content

refactor: extract shared createSandbox function#48

Merged
robbycochran merged 1 commit into
mainfrom
rc/phase2-shared-createsandbox
Jun 8, 2026
Merged

refactor: extract shared createSandbox function#48
robbycochran merged 1 commit into
mainfrom
rc/phase2-shared-createsandbox

Conversation

@robbycochran

Copy link
Copy Markdown
Collaborator

Summary

  • Extracts the near-duplicate sandbox creation logic from upLocal (cmd/up.go) and createDirect (cmd/create.go) into a shared createSandbox function in a new cmd/sandbox.go file
  • The shared function handles: image path resolution, harness dir staging, sandbox creation with 5-attempt retry loop, and best-effort cleanup on failure
  • Both callers become thin wrappers that build a sandboxOpts struct capturing their specific parameters (noTTY, retrySleep, sandboxCmd, onSuccess callback) then delegate to createSandbox

Test plan

  • All existing tests in cmd/up_test.go pass (including retry, SandboxCreateOpts, missing providers)
  • All existing tests in cmd/create_test.go pass (including no providers, with providers, sandbox name)
  • CGO_ENABLED=0 go test ./cmd/... passes
  • go vet ./... passes
  • No changes to internal/ packages, providers.toml, go.work, or files outside cmd/

🤖 Generated with Claude Code

Both upLocal (up.go) and createDirect (create.go) contained near-duplicate
sandbox creation logic: image resolution, file staging, retry loop, and
failure cleanup. Extract this into a single createSandbox function in
cmd/sandbox.go, parameterized by a sandboxOpts struct that captures the
differences (noTTY, retrySleep, sandboxCmd, onSuccess callback).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@robbycochran robbycochran merged commit e86d3cc into main Jun 8, 2026
4 checks passed
@robbycochran robbycochran deleted the rc/phase2-shared-createsandbox branch June 13, 2026 14:03
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