deploy local: abort immediately when Docker is unavailable#75
Conversation
Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the gh devlake deploy local UX by making the Docker availability check blocking and reusing the existing shared Docker helper, preventing a confusing docker compose up failure path when Docker isn’t running.
Changes:
- Replaced the inline
docker versionavailability check withinternal/docker.CheckAvailable(). - Aborts
deploy localimmediately when Docker is unavailable, after printing actionable guidance.
cmd/deploy_local.go
Outdated
| if err := dockerpkg.CheckAvailable(); err != nil { | ||
| fmt.Println(" ❌ Docker not found or not running") | ||
| fmt.Println(" Install Docker Desktop: https://docs.docker.com/get-docker") | ||
| } else { | ||
| fmt.Printf(" ✅ Docker %s found\n", strings.TrimSpace(string(dockerOut))) | ||
| fmt.Println(" Start Docker Desktop, then re-run: gh devlake deploy local") | ||
| return fmt.Errorf("docker unavailable: %w", err) |
There was a problem hiding this comment.
runDeployLocal prints the friendly Docker guidance, but then returns a wrapped error (docker unavailable: %w). Because cmd.Execute() always prints the returned error to stderr, users will still see a trailing low-level docker version failure (often including the Windows named-pipe message) which undermines the goal of avoiding confusing output. Consider returning a concise, user-facing error string (without wrapping the underlying exec error), or using a dedicated error type/handling path that preserves the underlying error for debugging while keeping the default terminal message clean.
There was a problem hiding this comment.
Fixed in 7cefc6b — the return now uses fmt.Errorf("Docker is not available — start Docker Desktop and retry") (no %w wrapping), so Cobra only prints the clean message to stderr and the raw exec/pipe error is suppressed.
|
@copilot Fix the error return so users don't see ugly low-level output: When Docker is unavailable, Fix: After printing the user-friendly guidance, return a clean, concise error without wrapping the underlying exec error. For example: fmt.Println("\n🐳 Checking Docker...")
if err := docker.CheckAvailable(); err != nil {
fmt.Println(" ❌ Docker not found or not running")
fmt.Println(" Install Docker Desktop: https://docs.docker.com/get-docker")
fmt.Println(" Start Docker Desktop, then re-run: gh devlake deploy local")
return fmt.Errorf("Docker is not available — start Docker Desktop and retry")
}The key change: |
Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Done in 7cefc6b — changed to |
dockerpkg.CheckAvailable()and abort on failurego build ./...,go test ./...,go vet ./...all passOriginal prompt
deploy local: Docker check should abort when Docker is unavailable #69🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.