Skip to content

fix: deduplicate VRF/host-interface checks in cmdCheck and cmdStatus#179

Merged
privateip merged 1 commit into
mainfrom
fix/issue-168
Jun 30, 2026
Merged

fix: deduplicate VRF/host-interface checks in cmdCheck and cmdStatus#179
privateip merged 1 commit into
mainfrom
fix/issue-168

Conversation

@privateip

Copy link
Copy Markdown
Contributor

Extract the duplicated VRF existence and host-interface existence checks shared between cmdCheck and cmdStatus into a single checkNodeLevelState helper. Both operations previously ran the same vrf.Exists() + netlink.LinkByName() sequence with identical error formatting, creating a maintenance risk for future drift.

  • Extract checkNodeLevelState helper that validates VRF and host interface existence, returning the host interface name and accumulated errors
  • Replace inline VRF/host checks in cmdCheck with a call to the helper
  • Replace inline VRF/host checks in cmdStatus with a call to the helper
  • Preserve hostName return value in cmdCheck for subsequent prevResult validation without duplicating GenerateInterfaceNameHost

fixes #168

Extract the duplicated VRF existence and host-interface existence checks
shared between cmdCheck and cmdStatus into a single checkNodeLevelState
helper. Both operations previously ran the same vrf.Exists() +
netlink.LinkByName() sequence with identical error formatting, creating
a maintenance risk for future drift.

- Extract checkNodeLevelState helper that validates VRF and host interface
  existence, returning the host interface name and accumulated errors
- Replace inline VRF/host checks in cmdCheck with a call to the helper
- Replace inline VRF/host checks in cmdStatus with a call to the helper
- Preserve hostName return value in cmdCheck for subsequent prevResult
  validation without duplicating GenerateInterfaceNameHost

fixes #168
@privateip privateip requested a review from a team as a code owner June 30, 2026 20:54
@privateip privateip requested a review from AriaEdo June 30, 2026 20:54
@privateip privateip merged commit 4e093af into main Jun 30, 2026
5 checks passed
@privateip privateip deleted the fix/issue-168 branch June 30, 2026 21:01
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.

Deduplicate VRF/host-interface checks shared between cmdCheck and cmdStatus

2 participants