Skip to content

feat: enhance version command with more info for debug#1243

Merged
rsdmike merged 1 commit intonextfrom
version
Apr 6, 2026
Merged

feat: enhance version command with more info for debug#1243
rsdmike merged 1 commit intonextfrom
version

Conversation

@rsdmike
Copy link
Copy Markdown
Member

@rsdmike rsdmike commented Apr 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 3, 2026 16:52
@rsdmike rsdmike force-pushed the version branch 2 times, most recently from 28eac74 to 4364dba Compare April 3, 2026 16:56
Copy link
Copy Markdown

Copilot AI left a comment

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 enhances the version command to provide richer debug-friendly build/runtime metadata, and updates build/test plumbing to support it.

Changes:

  • Add build metadata variables (BuildDate, BuildCommit) and embed them via go build -ldflags in build.sh.
  • Expand version command output (JSON + styled text) to include commit/date/Go version/platform.
  • Update tests for the new version output, and adjust AMTBaseCmd.AfterApply retry behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/utils/constants.go Introduces build metadata globals (BuildDate, BuildCommit) used by the version command.
internal/commands/version.go Extends version output with build/runtime info and adds styled text rendering.
internal/commands/version_test.go Updates assertions to cover new JSON fields and styled output content; disables lipgloss colors in tests.
internal/commands/base.go Changes GetControlMode retry loop behavior (affects SkipWSMANSetup flows).
build.sh Adds build date/commit capture and injects them into binaries via -X ldflags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to 28
func init() {
// Disable colors in tests so assertions match plain text.
lipgloss.SetColorProfile(termenv.Ascii)
}

func TestVersionCmd_Run_PlainText(t *testing.T) {
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This package-level init() mutates global lipgloss state for the entire commands test package, which can create hidden coupling with other tests (and makes it harder to re-enable colors for specific assertions). Prefer using TestMain to set/restore global state, or set the color profile within the specific tests that capture output and restore it via t.Cleanup.

Suggested change
func init() {
// Disable colors in tests so assertions match plain text.
lipgloss.SetColorProfile(termenv.Ascii)
}
func TestVersionCmd_Run_PlainText(t *testing.T) {
func setASCIIColorProfile(t *testing.T) {
t.Helper()
previousProfile := lipgloss.ColorProfile()
lipgloss.SetColorProfile(termenv.Ascii)
t.Cleanup(func() {
lipgloss.SetColorProfile(previousProfile)
})
}
func TestVersionCmd_Run_PlainText(t *testing.T) {
setASCIIColorProfile(t)

Copilot uses AI. Check for mistakes.
Comment on lines +145 to 149
for attempt := 1; attempt <= maxAttempts; attempt++ {
controlMode, err = amtCommand.GetControlMode()
if err == nil {
break
}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This retry loop now always uses maxAttempts even when SkipWSMANSetup is true. Previously (per the removed effectiveMaxAttempts logic) SkipWSMANSetup avoided the backoff/retry delay, letting commands like amtinfo degrade quickly when HECI is unavailable. If the intent is still to be fast for SkipWSMANSetup, consider restoring the reduced-attempt behavior to avoid up to ~12s delay before falling back.

Copilot uses AI. Check for mistakes.
effectiveMaxAttempts := maxAttempts

for attempt := 1; attempt <= effectiveMaxAttempts; attempt++ {
for attempt := 1; attempt <= maxAttempts; attempt++ {
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This change modifies AMTBaseCmd.AfterApply retry behavior (unrelated to the PR’s stated goal of enhancing the version command). If this is intentional, it would help to move it into a separate PR or document the rationale here; otherwise it risks introducing behavior changes that reviewers may miss when focusing on the version output work.

Copilot uses AI. Check for mistakes.
@rsdmike rsdmike force-pushed the version branch 2 times, most recently from 3eb171b to 39d83fc Compare April 3, 2026 17:09
@rsdmike rsdmike merged commit 04df712 into next Apr 6, 2026
13 checks passed
@rsdmike rsdmike deleted the version branch April 6, 2026 19:44
@graikhel-intel graikhel-intel linked an issue Apr 7, 2026 that may be closed by this pull request
5 tasks
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.

Allow non-admin access for version and basic amtinfo in rpc-go

3 participants