Skip to content

feat(network): improve service network output clarity#225

Merged
yuaanlin merged 2 commits intomainfrom
feat/improve-service-network-output
Apr 12, 2026
Merged

feat(network): improve service network output clarity#225
yuaanlin merged 2 commits intomainfrom
feat/improve-service-network-output

Conversation

@yuaanlin
Copy link
Copy Markdown
Member

@yuaanlin yuaanlin commented Apr 12, 2026

Summary

  • Restructure service network output into Private Networking and Public Networking sections
  • Each port shows its type (TCP/HTTP/UDP) and access method:
    • TCP/UDP: forwarded host:port, or prompt to enable port forwarding
    • HTTP: indicates domain binding is needed
  • Always fetch ports (not only when port forwarding is enabled) so private networking info is always shown
  • JSON output also always includes ports array

Before

INFO  Private DNS name for : mysql.zeabur.internal
INFO  Port forwarding: ENABLED
INFO    database (TCP 3306) → 35.243.251.153:31476

After

INFO  Private Networking (between services on Zeabur)
INFO    database (TCP): mysql.zeabur.internal:3306

INFO  Public Networking (connect from outside Zeabur)
INFO    database (TCP): 35.243.251.153:31476

Test plan

  • service network with TCP service (port forwarding enabled) — shows forwarded host:port
  • service network with TCP service (port forwarding disabled) — shows warning + enable command
  • service network with HTTP service — shows "bind a domain to access externally"
  • service network --json — ports array always present regardless of port forwarding state

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Removed redundant port retrieval and ensured port information is consistently included when an environment is specified.
    • Added early handling and clear warnings when no service ports are found.
  • Improvements

    • Reorganized output to separate Private and Public networking sections.
    • Shows all service ports with type, internal host and port.
    • Improved port forwarding messages: HTTP access lines, forwarded addresses when available, and clear enable-forwarding guidance.

…tions

Restructure `service network` output to clearly separate:

- **Private Networking** (between services on Zeabur): shows
  internal hostname:port for each port
- **Public Networking** (connect from outside Zeabur): per-port
  guidance — TCP/UDP ports show forwarded host:port or prompt to
  enable port forwarding; HTTP ports indicate domain binding is needed

Also fetch ports unconditionally (not only when port forwarding is
enabled) so private networking always shows port info. JSON output
updated accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7304fd05-41f5-4b27-8c3f-8cb9856d48ff

📥 Commits

Reviewing files that changed from the base of the PR and between 9fed03d and f6d8327.

📒 Files selected for processing (1)
  • internal/cmd/service/network/network.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/cmd/service/network/network.go

Walkthrough

Port retrieval was moved earlier when an environment ID is provided; JSON output now always includes the pre-fetched ports in that case. Non-JSON output was reorganized into "Private Networking" and "Public Networking" sections with new messaging for HTTP ports and port-forwarding states, plus early handling when no ports exist.

Changes

Cohort / File(s) Summary
Service Network Output Refactoring
internal/cmd/service/network/network.go
Fetches service ports immediately when opts.environmentID != ""; removes redundant GetServicePorts call. JSON output always includes ports when environment ID present. Non-JSON output restructured: prints "Private Networking" listing all ports with internal host, then "Public Networking" with HTTP-specific external access lines or forwarded address/warnings when forwarding disabled. Adds early return when no ports found and adjusts related logging and error handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the changeset: restructuring service network output for improved clarity with Private and Public Networking sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/improve-service-network-output

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/cmd/service/network/network.go`:
- Around line 145-151: The current printing always emits the "Private
Networking" and "Public Networking" headers even when there are no ports; update
the logic around the loops that print ports (the slices ports and publicPorts
and the variables internalHost/externalHost) to only print each section header
if the corresponding slice is non-empty (or environmentID is present), otherwise
print a short fallback line like "No private ports configured" / "No public
ports configured" or skip the section entirely; ensure you modify the blocks
that call f.Log.Infof (and the fmt.Println()) so headers and blank lines are
conditional around the loops that iterate over ports and publicPorts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5dcd2be1-2c8c-44c9-8898-7f3565f62b1b

📥 Commits

Reviewing files that changed from the base of the PR and between 0260690 and 9fed03d.

📒 Files selected for processing (1)
  • internal/cmd/service/network/network.go

When no ports are configured or no environment is specified, show the
DNS name with a warning instead of printing empty section headers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yuaanlin yuaanlin merged commit 2777968 into main Apr 12, 2026
4 checks passed
@yuaanlin yuaanlin deleted the feat/improve-service-network-output branch April 12, 2026 04:02
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