Repository navigation
feat(tools): add macOS support to bm-dns-setup script - #347
Conversation
Review Summary by QodoAdd macOS support to bm-dns-setup script
WalkthroughsDescription• Add macOS support via /etc/resolver configuration • Auto-detect OS and route to platform-specific implementations • Refactor Linux logic into dedicated enable/disable functions • Update usage documentation for cross-platform clarity Diagramflowchart LR
A["bm-dns-setup.sh"] --> B["OS Detection<br/>uname -s"]
B --> C["Linux Path"]
B --> D["macOS Path"]
C --> E["enable_linux/<br/>disable_linux<br/>resolvectl"]
D --> F["enable_macos/<br/>disable_macos<br/>/etc/resolver"]
File Changes1. tools/bm-dns-setup.sh
|
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
Code Review by Qodo
1. Trailing-dot domain accepted
|
- Auto-detect OS via uname -s (Linux: resolvectl, macOS: /etc/resolver) - Add --domain flag (default: mtv.local) - Add IP validation - Extract OS dispatch to functions (no duplicate code)
de1e5a2 to
c531a0d
Compare
|
Persistent review updated to latest commit c531a0d |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughRefactors Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Script as bm-dns-setup.sh
participant OS as OS (systemd-resolved / macOS)
participant Net as Network Interface
User->>Script: run enable/disable --domain [--ip]
Script->>Script: validate_domain(domain)\nvalidate_ip(ip)?
alt validation fails
Script-->>User: error and exit
else validation passes
Script->>Script: get_domain_interface(domain)
Script->>OS: run_enable/run_disable -> enable_* / disable_*(domain, ip)
OS->>Net: apply DNS config for domain (resolvectl or /etc/resolver)
OS-->>Script: success/failure
Script-->>User: success or error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
|
/approve |
|
Persistent review updated to latest commit c531a0d |
|
/verified |
Code Review by QodoNew Review StartedThis review has been superseded by a new analysisⓘ The new review experience is currently in Beta. Learn more |
|
Persistent review updated to latest commit 9bfd911 |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
tools/bm-dns-setup.sh (1)
165-184: 🛠️ Refactor suggestion | 🟠 MajorMEDIUM: Extract duplicate option-parsing logic into a helper function.
The
whileloops at lines 165-172 and 178-184 are identical. This violates DRY and makes future changes error-prone (e.g., adding a new option requires updating two places).♻️ Proposed refactor
+parse_options() { + while [[ $# -gt 0 ]]; do + case "$1" in + --domain) + [[ -n "${2:-}" ]] || die "--domain requires a value" + DOMAIN="$2"; shift 2 ;; + *) die "Unknown option: $1" ;; + esac + done +} + case "$ACTION" in enable) [[ $# -ge 1 ]] || { echo "$USAGE" >&2; exit 1; } IP="$1" shift - while [[ $# -gt 0 ]]; do - case "$1" in - --domain) - [[ -n "${2:-}" ]] || die "--domain requires a value" - DOMAIN="$2"; shift 2 ;; - *) die "Unknown option: $1" ;; - esac - done + parse_options "$@" validate_ip "$IP" validate_domain "$DOMAIN" run_enable "$IP" "$DOMAIN" ;; disable) - while [[ $# -gt 0 ]]; do - case "$1" in - --domain) - [[ -n "${2:-}" ]] || die "--domain requires a value" - DOMAIN="$2"; shift 2 ;; - *) die "Unknown option: $1" ;; - esac - done + parse_options "$@" validate_domain "$DOMAIN" run_disable "$DOMAIN" ;; esac🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/bm-dns-setup.sh` around lines 165 - 184, Extract the duplicated option-parsing while-loop into a helper function (e.g., parse_domain_option) that reads "--domain" into the global DOMAIN variable, performs the same validation and shifting, and calls die for unknown options; then replace the two identical while loops in the "enable" and "disable" case branches with a single call to parse_domain_option and leave the subsequent validate_domain and run_enable (and the corresponding run_disable) calls in place so behavior is unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@tools/bm-dns-setup.sh`:
- Around line 165-184: Extract the duplicated option-parsing while-loop into a
helper function (e.g., parse_domain_option) that reads "--domain" into the
global DOMAIN variable, performs the same validation and shifting, and calls die
for unknown options; then replace the two identical while loops in the "enable"
and "disable" case branches with a single call to parse_domain_option and leave
the subsequent validate_domain and run_enable (and the corresponding
run_disable) calls in place so behavior is unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e1325eac-9014-447d-bda1-9b03c4538278
📒 Files selected for processing (1)
tools/bm-dns-setup.sh
|
Persistent review updated to latest commit b2376af |
|
/verified |
|
Persistent review updated to latest commit b2376af |
|
/approve Please check the unresolved comment |
|
/check-can-merge |
Add macOS support to the bare-metal DNS setup script.
The script auto-detects the OS (
uname -s) and uses/etc/resolveron macOS.Linux behavior is unchanged.
Tested on macOS
Summary by CodeRabbit
New Features
Documentation