feat: Add rack and tray lifecycle and task commands to TUI#535
Conversation
Signed-off-by: Kyle Felter <kfelter@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Summary by CodeRabbit
WalkthroughThis PR extends the CLI TUI with complete tray resource management, adding tray data fetching with site scoping, user commands for listing and managing tray/rack lifecycle operations, shared infrastructure for scope enforcement and task handling, command registration, REPL autocomplete support, and comprehensive test coverage. ChangesTray Resource Management and Lifecycle Operations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔐 TruffleHog Secret Scan✅ No secrets or credentials found! Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉 🕐 Last updated: 2026-05-15 19:29:50 UTC | Commit: ccf1e4f |
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
|
Resolves #524 |
thossain-nv
left a comment
There was a problem hiding this comment.
Looks good, thanks @kfelternv
There was a problem hiding this comment.
🧹 Nitpick comments (2)
cli/tui/cache.go (1)
70-76: ⚡ Quick winCentralize the filtered resource registry.
This roster now has to stay in sync with
appendScopeFlagsand the other resource registries, and the tray / expected-* additions already touched multiple copies in this PR. A shared constant or helper would make the next scoped resource much harder to partially wire.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cli/tui/cache.go` around lines 70 - 76, The hardcoded resource list inside Cache.InvalidateFiltered must be centralized so it stays in sync with other registries (e.g., appendScopeFlags); extract the literal slice into a single shared symbol (for example a package-level constant or a small accessor function like filteredResources() or FilteredResourceRegistry) and replace the inline list in InvalidateFiltered with a reference to that shared symbol; update other callers (appendScopeFlags and any other registry usages) to use the same shared symbol so additions/removals only happen in one place.cli/tui/commands.go (1)
3179-3184: ⚡ Quick winSplit the inline unmarshal from the condition.
This is the one new place in the file that diverges from the repo’s preferred Go style. Pulling the unmarshal into its own statement keeps the parse path explicit and consistent with the rest of the TUI command code.
♻️ Suggested change
func printTaskIDs(body []byte, action string) error { var resp struct { TaskIDs []string `json:"taskIds"` } - if err := json.Unmarshal(body, &resp); err == nil && len(resp.TaskIDs) > 0 { + err := json.Unmarshal(body, &resp) + if err == nil && len(resp.TaskIDs) > 0 { fmt.Printf("%s %s started; %d task(s):\n", Green("OK"), action, len(resp.TaskIDs)) for _, id := range resp.TaskIDs { fmt.Printf(" %s\n", id) } fmt.Println()As per coding guidelines, "Prefer split assign-and-condition into two statements:
derr := action(); if derr != nil { ... }instead of inlineif derr := action(); derr != nil { ... }".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cli/tui/commands.go` around lines 3179 - 3184, The json.Unmarshal call inside the if statement in printTaskIDs should be split into two statements for clarity and style: first call json.Unmarshal(body, &resp) and assign its error to a variable (e.g., err), then use if err == nil && len(resp.TaskIDs) > 0 { ... } (or handle the error case explicitly) so the parse path is explicit and consistent with other TUI command code; update the function printTaskIDs to perform the unmarshal before the conditional that checks len(resp.TaskIDs).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cli/tui/cache.go`:
- Around line 70-76: The hardcoded resource list inside Cache.InvalidateFiltered
must be centralized so it stays in sync with other registries (e.g.,
appendScopeFlags); extract the literal slice into a single shared symbol (for
example a package-level constant or a small accessor function like
filteredResources() or FilteredResourceRegistry) and replace the inline list in
InvalidateFiltered with a reference to that shared symbol; update other callers
(appendScopeFlags and any other registry usages) to use the same shared symbol
so additions/removals only happen in one place.
In `@cli/tui/commands.go`:
- Around line 3179-3184: The json.Unmarshal call inside the if statement in
printTaskIDs should be split into two statements for clarity and style: first
call json.Unmarshal(body, &resp) and assign its error to a variable (e.g., err),
then use if err == nil && len(resp.TaskIDs) > 0 { ... } (or handle the error
case explicitly) so the parse path is explicit and consistent with other TUI
command code; update the function printTaskIDs to perform the unmarshal before
the conditional that checks len(resp.TaskIDs).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 87136334-6e1f-457a-b3cb-094b9963b00d
📒 Files selected for processing (5)
cli/tui/cache.gocli/tui/commands.gocli/tui/commands_test.gocli/tui/repl.gocli/tui/session.go
✅ Files skipped from review due to trivial changes (1)
- cli/tui/repl.go
Rack and tray lifecycle commands are useful to have in the tui, so that users dont have to know uuids of resources before running the command. This PR adds various commands to the interactive mode of the cli for rack and tray lifecycle commands like rack bringup.