Skip to content

add caib show#93

Merged
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:caib-show
Feb 11, 2026
Merged

add caib show#93
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:caib-show

Conversation

@bennyz

@bennyz bennyz commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added a new show command to display detailed build information in JSON, YAML, or table formats.
  • Changed

    • Updated follow logs flag (-f/--follow) to default to true across build commands.
    • Redesigned download command to use positional arguments instead of named flags.
    • Changed artifacts output flag to -o/--output format.

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@coderabbitai

coderabbitai Bot commented Feb 10, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request introduces a new show command to the caib CLI for displaying detailed build information, modifies the download command's interface to use positional arguments and new flags, changes default behavior of the follow logs flag to true, and extends the BuildResponse API payload with structured build parameters data.

Changes

Cohort / File(s) Summary
Documentation
cmd/caib/README.md
Updated command usage documentation to reflect new show command, changed download command to positional argument syntax, and changed -f/--follow default to true for build/disk/build-dev commands.
CLI Implementation
cmd/caib/main.go
Implemented new show command with GetBuild/GetBuildTemplate API calls, support for JSON/YAML/table output formats, and helper functions for tabular display and output normalization.
API Client
internal/buildapi/client/client.go
Added GetBuildTemplate() method for fetching build templates, refactored ListBuilds and ListFlash to use new listJSON() helper for consistent JSON decoding and error handling.
API Types & Server
internal/buildapi/server.go, internal/buildapi/types.go
Introduced BuildParameters struct containing build input snapshot (architecture, distro, mode, storage class, etc.) and extended BuildResponse to include optional Parameters field.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI (show command)
    participant Client as API Client
    participant Server as API Server
    
    User->>CLI: caib show build-name
    CLI->>Client: GetBuild(ctx, "build-name")
    Client->>Server: GET /v1/builds/build-name
    Server-->>Client: BuildResponse
    
    alt Parameters missing
        CLI->>Client: GetBuildTemplate(ctx, "build-name")
        Client->>Server: GET /v1/builds/build-name/template
        Server-->>Client: BuildTemplateResponse
        CLI->>CLI: Populate Parameters from template
    end
    
    CLI->>CLI: Format output (JSON/YAML/table)
    CLI-->>User: Display formatted build details
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly Related PRs

  • automotive-dev-operator#79: Touches caib CLI command definitions and BuildResponse API payload structure, with overlapping changes to build API surface.

Poem

🐰 A show command hops into view,
Templates and parameters—fresh morning dew!
BuildResponse now rich with detail and care,
JSON, YAML, tables—output everywhere!
The API blooms with structured display,
Build wisdom revealed in every way! 🌱

🚥 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 'add caib show' is concise and clearly describes the primary change: introducing a new 'show' command to the caib CLI tool, which aligns with the main functionality added across multiple files (new showCmd, show subcommand, and related output formatting).

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@cmd/caib/main.go`:
- Around line 1949-1959: The current fallback call to executeWithReauth ignores
errors and swallows failures when st.Parameters is nil; update the block so you
capture the returned error from executeWithReauth(...) and, if non-nil, write a
clear warning to stderr that includes context (e.g., "failed to fetch build
template for showBuildName" or similar) and the actual error value rather than
discarding it; keep the existing behavior of setting st.Parameters =
buildParametersFromTemplate(tpl) on success and only log (not fatal) on failure
so users see why parameters are missing.
🧹 Nitpick comments (3)
cmd/caib/README.md (1)

255-262: Note: -o flag semantics differ between show and download.

In show, -o controls output format (table/json/yaml), while in download, -o specifies the destination file path. This is documented correctly but worth calling out for users who switch between the two commands. Consider whether --format might be clearer for show to avoid ambiguity.

internal/buildapi/types.go (1)

224-240: omitempty on bool fields suppresses false in JSON/YAML output.

Fields like BuildDiskImage, FlashEnabled, and UseServiceAccountAuth will be omitted from JSON/YAML when false. This means caib show -o json won't distinguish "explicitly false" from "field absent." If that distinction matters for consumers, remove omitempty from these bool fields.

If the intent is purely supplementary info where absence implies false, this is fine as-is.

cmd/caib/main.go (1)

2003-2018: Consider simplifying the all-fields-empty check with reflect.DeepEqual.

The exhaustive field-by-field zero check is correct but fragile — adding a new field to BuildParameters requires updating this check too. A simpler alternative:

if *params == (buildapitypes.BuildParameters{}) {
    return nil
}

This compares against the zero value of the struct in one expression and stays in sync as fields are added.

Comment thread cmd/caib/main.go
Comment on lines +1949 to +1959
// Backward-compatible fallback for older API servers that do not yet include response parameters.
if st.Parameters == nil {
_ = executeWithReauth(serverURL, &authToken, func(api *buildapiclient.Client) error {
tpl, err := api.GetBuildTemplate(ctx, showBuildName)
if err != nil {
return err
}
st.Parameters = buildParametersFromTemplate(tpl)
return nil
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Silently swallowing template fallback errors hides legitimate failures.

When Parameters is nil (older server), the template fetch error is discarded with _ = executeWithReauth(...). If the failure is due to a network error, auth issue, or server bug (not just a missing endpoint), the user sees no parameters with no explanation.

Consider logging a warning to stderr on failure:

Suggested improvement
 	if st.Parameters == nil {
-		_ = executeWithReauth(serverURL, &authToken, func(api *buildapiclient.Client) error {
+		err := executeWithReauth(serverURL, &authToken, func(api *buildapiclient.Client) error {
 			tpl, err := api.GetBuildTemplate(ctx, showBuildName)
 			if err != nil {
 				return err
 			}
 			st.Parameters = buildParametersFromTemplate(tpl)
 			return nil
 		})
+		if err != nil {
+			fmt.Fprintf(os.Stderr, "Warning: could not fetch build parameters: %v\n", err)
+		}
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Backward-compatible fallback for older API servers that do not yet include response parameters.
if st.Parameters == nil {
_ = executeWithReauth(serverURL, &authToken, func(api *buildapiclient.Client) error {
tpl, err := api.GetBuildTemplate(ctx, showBuildName)
if err != nil {
return err
}
st.Parameters = buildParametersFromTemplate(tpl)
return nil
})
}
// Backward-compatible fallback for older API servers that do not yet include response parameters.
if st.Parameters == nil {
err := executeWithReauth(serverURL, &authToken, func(api *buildapiclient.Client) error {
tpl, err := api.GetBuildTemplate(ctx, showBuildName)
if err != nil {
return err
}
st.Parameters = buildParametersFromTemplate(tpl)
return nil
})
if err != nil {
fmt.Fprintf(os.Stderr, "Warning: could not fetch build parameters: %v\n", err)
}
}
🤖 Prompt for AI Agents
In `@cmd/caib/main.go` around lines 1949 - 1959, The current fallback call to
executeWithReauth ignores errors and swallows failures when st.Parameters is
nil; update the block so you capture the returned error from
executeWithReauth(...) and, if non-nil, write a clear warning to stderr that
includes context (e.g., "failed to fetch build template for showBuildName" or
similar) and the actual error value rather than discarding it; keep the existing
behavior of setting st.Parameters = buildParametersFromTemplate(tpl) on success
and only log (not fatal) on failure so users see why parameters are missing.

@bennyz bennyz requested a review from bkhizgiy February 11, 2026 07:25
@bennyz bennyz merged commit 9ff6a82 into centos-automotive-suite:main Feb 11, 2026
4 checks passed
@bennyz bennyz deleted the caib-show branch February 11, 2026 08:16
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.

2 participants