Skip to content

refactor: split cli_show_interfaces.go per render mode (#4654)#4681

Merged
psaab merged 1 commit into
masterfrom
refactor/4654-show-interfaces-split
Jul 8, 2026
Merged

refactor: split cli_show_interfaces.go per render mode (#4654)#4681
psaab merged 1 commit into
masterfrom
refactor/4654-show-interfaces-split

Conversation

@psaab

@psaab psaab commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Splits the 1396-LOC pkg/cli/cli_show_interfaces.go per render mode plus a
shared RETH/kernel-query helper file. The RETH / physical-member display
logic repeated across the summary/terse/detail/extensive modes and drifted
(the #4328 family of fixes) — collecting the shared helpers in one place
removes the drift surface. Pure code motion, behavior-identical: no logic,
output text, or netlink/sysfs query order changed.

New layout (same package — unexported helpers stay reachable)

File Declarations LOC
cli_show_interfaces.go showInterfaces (dispatch + summary), showInterfacesRethMemberSummary, showTunnelInterfaces 486
cli_show_interfaces_terse.go showInterfacesTerse 316
cli_show_interfaces_detail.go showInterfacesDetail, showInterfacesRethDetail (reused by extensive) 265
cli_show_interfaces_extensive.go showInterfacesExtensive / …Filtered 207
cli_show_interfaces_stats.go showInterfacesStatistics, showVlans 110
cli_show_interfaces_shared.go dhcpLease, rethMemberLinkState, rethMemberAttrs, baseIfName 62

Validation

Closes #4654

🤖 Generated with Claude Code

https://claude.ai/code/session_015oARShYtiJJ2H4UB4nXGqi

pkg/cli/cli_show_interfaces.go had grown to 1396 LOC, and the RETH /
physical-member display logic repeated across the summary, terse, detail,
and extensive render modes. That duplication is exactly where the #4328
family of fixes kept drifting between modes. Splitting the file per render
mode and pulling the shared RETH/kernel-query helpers into one file removes
the drift surface: the four modes now resolve reth link state, member
attrs, and lease data through a single place.

This is a pure code-motion change. Every top-level declaration was moved
verbatim; no logic, output text, or netlink/sysfs query order changed.

New layout (same package, so unexported helpers stay reachable):

  cli_show_interfaces.go          showInterfaces dispatch + summary,
                                  showInterfacesRethMemberSummary,
                                  showTunnelInterfaces
  cli_show_interfaces_terse.go    showInterfacesTerse
  cli_show_interfaces_detail.go   showInterfacesDetail +
                                  showInterfacesRethDetail (reused by
                                  the extensive view)
  cli_show_interfaces_extensive.go showInterfacesExtensive[Filtered]
  cli_show_interfaces_stats.go    showInterfacesStatistics, showVlans
  cli_show_interfaces_shared.go   dhcpLease, rethMemberLinkState,
                                  rethMemberAttrs, baseIfName

Validation:
  - go/parser decl-diff of origin/master's single file against the union
    of the six new files: identical=14, bodydiff=0, missing=0, extra=0 —
    all 14 top-level declarations byte-for-byte identical.
  - go build ./... clean; go vet ./pkg/cli/... reports only the
    pre-existing cli.go:503 unreachable-code note (untouched file).
  - go test ./pkg/cli/... green, including the #4328 (RETH) and #3654
    (host-inbound) output tests that assert the exact rendered text across
    the summary/detail/extensive/member paths — the visible-output
    byte-identity gate.
  - gofmt clean on all six files.

Closes #4654

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oARShYtiJJ2H4UB4nXGqi
Copilot AI review requested due to automatic review settings July 8, 2026 15:59
@psaab
psaab merged commit 8bd2c30 into master Jul 8, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors show interfaces presentation code by splitting the former monolithic pkg/cli/cli_show_interfaces.go into per-render-mode files plus a small shared helper file for RETH/kernel-query helpers, aiming to eliminate renderer drift while keeping behavior and output unchanged.

Changes:

  • Split show interfaces into dedicated files for summary/dispatch, terse, detail (incl. shared RETH detail renderer), extensive, and statistics/VLANs.
  • Centralize shared helpers (dhcpLease, RETH member link-state / attrs, baseIfName) into cli_show_interfaces_shared.go.
  • Document the new layout in pkg/cli/README.md and record the refactor in _Log.md.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/cli/README.md Documents the new per-renderer file layout for show interfaces and the shared helper surface.
pkg/cli/cli_show_interfaces.go Retains dispatch + summary renderer and member-summary path; delegates terse/detail/extensive/stats to split files.
pkg/cli/cli_show_interfaces_terse.go Holds the show interfaces terse tabular renderer.
pkg/cli/cli_show_interfaces_detail.go Holds show interfaces ... detail renderer and the shared showInterfacesRethDetail block reused by extensive.
pkg/cli/cli_show_interfaces_extensive.go Holds show interfaces extensive and ... extensive <if> renderer.
pkg/cli/cli_show_interfaces_stats.go Holds show interfaces statistics and show vlans presenters.
pkg/cli/cli_show_interfaces_shared.go Shared DHCP + RETH/kernel-query helpers to prevent drift across renderers.
_Log.md Logs the refactor action and touched files per repo conventions.

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.

refactor: pkg/cli/cli_show_interfaces.go (1396 LOC) — split per-renderer + shared RETH/kernel helpers

2 participants