-
Notifications
You must be signed in to change notification settings - Fork 0
fix: unnecessary password prompts for hosts and cert #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughHosts management now reports whether the hosts file changed (Save returns (bool, error)), runHostsUpdate retries via sudo on first-time save errors and prints a conditional update message. Project state no longer stores HasHosts and host entries are deterministically sorted. macOS cert check now iterates multiple PEM blocks. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas needing extra attention:
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🧰 Additional context used📓 Path-based instructions (3)internal/**/*.go⚙️ CodeRabbit configuration file
Files:
internal/project/**/*.go⚙️ CodeRabbit configuration file
Files:
cmd/devbox/**/*.go⚙️ CodeRabbit configuration file
Files:
🧬 Code graph analysis (1)cmd/devbox/up.go (4)
🔇 Additional comments (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
internal/hosts/hosts_test.gois excluded by!**/*_test.go
📒 Files selected for processing (5)
cmd/devbox/up.gointernal/cert/cert_darwin.gointernal/hosts/hosts.gointernal/project/project.gointernal/project/struct.go
🧰 Additional context used
📓 Path-based instructions (3)
internal/**/*.go
⚙️ CodeRabbit configuration file
internal/**/*.go: Core packages providing project functionality:
- project/: Project configuration, Docker Compose extensions (x-devbox-*)
- manager/: Project/service autodetection from current directory
- git/: Git operations (clone, sparse checkout, sync)
- cert/: SSL certificate generation
- hosts/: /etc/hosts management with project-scoped markers
- table/: CLI table output formatting
Review for:
- Clean interfaces and proper encapsulation
- Error wrapping with context
- No interface{} - use 'any' instead (enforced by linter)
- YAGNI principle - no speculative features or premature abstractions
- Security considerations for host file and certificate operations
Files:
internal/project/struct.gointernal/hosts/hosts.gointernal/cert/cert_darwin.gointernal/project/project.go
internal/project/**/*.go
⚙️ CodeRabbit configuration file
internal/project/**/*.go: Project configuration extending Docker Compose with x-devbox extensions:
- x-devbox-sources: Repository definitions with branch and sparse checkout
- x-devbox-scenarios: Named command shortcuts
- x-devbox-hosts: /etc/hosts entries
- x-devbox-cert: SSL certificate domains
State is persisted in .devboxstate JSON file.
Mount system replaces volume binds with local paths.Review for proper parsing and validation of compose extensions.
Files:
internal/project/struct.gointernal/project/project.go
cmd/devbox/**/*.go
⚙️ CodeRabbit configuration file
cmd/devbox/**/*.go: This directory contains CLI commands using Cobra framework.
Each command is in a separate file with an init() function that registers via root.AddCommand().Review for:
- Proper error handling with context wrapping (fmt.Errorf with %w)
- Consistent command structure following existing patterns
- Appropriate use of runWrapper for context handling
- Clear, concise command descriptions
- No over-engineering - only implement what's needed
Files:
cmd/devbox/up.go
🧬 Code graph analysis (1)
cmd/devbox/up.go (1)
internal/hosts/hosts.go (1)
Save(19-21)
🔇 Additional comments (6)
internal/project/struct.go (1)
3-5: LGTM!Clean simplification of the state struct. Removing
HasHostsaligns with the deterministic hosts handling approach—the hosts file content itself is now the source of truth rather than persisted state.internal/project/project.go (2)
186-188: LGTM!Good defensive check. Prevents overwriting the initialized empty map (from line 85) with
nilwhen the state file exists but has no mounts.
120-123: LGTM!State persistence is now minimal and correct—only
Mountsneeds to be persisted since hosts file changes are detected by content comparison.internal/hosts/hosts.go (2)
17-21: LGTM!Clean API change. Returning
(changed bool, error)is idiomatic Go for operations where callers need to know if an action occurred.
57-59: LGTM!Correct handling of empty entries—existing blocks are removed without leaving empty markers, and no new blocks are added when there's nothing to write. Fixes the unnecessary writes issue.
Also applies to: 76-82
internal/cert/cert_darwin.go (1)
22-46: Solid fix for the multi-certificate matching issue.The loop correctly iterates all PEM blocks returned by
security find-certificate -a -p, continuing past parse errors and non-certificate blocks. UsingEqual()for comparison is the right approach, andpemTypeCertificateis properly defined as a constant in cert.go.
65ad91b to
b841e1e
Compare
b841e1e to
3d88a09
Compare
Fix unnecessary password prompts for hosts and cert operations
Problem: DevBox prompted for password on every devbox up even when no changes were needed.
Root causes:
Fixes:
Summary by CodeRabbit
Bug Fixes
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.