Skip to content

add --flash-cmd to override OperatorConfig#149

Merged
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:custom-flash-command
Mar 10, 2026
Merged

add --flash-cmd to override OperatorConfig#149
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:custom-flash-command

Conversation

@bennyz

@bennyz bennyz commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Add --flash-cmd to allow users to override the flashCmd set in the OperatorConfig

Summary by CodeRabbit

  • New Features
    • Added --flash-cmd flag to override the default flash command during image operations.
    • Flag available across build, disk, build-dev, and flash subcommands.
    • User-specified flash command now propagates through commands and is sent with build/flash requests.
    • User-provided flash command takes priority over operator/default settings when present.

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eee5ae25-f6a2-4d86-a6bd-642731e22f03

📥 Commits

Reviewing files that changed from the base of the PR and between 783b405 and bf1c422.

⛔ Files ignored due to path filters (1)
  • config/crd/bases/automotive.sdv.cloud.redhat.com_imagebuilds.yaml is excluded by !config/crd/bases/**
📒 Files selected for processing (9)
  • api/v1alpha1/imagebuild_types.go
  • cmd/caib/buildcmd/build.go
  • cmd/caib/flashcmd/flash.go
  • cmd/caib/image/image.go
  • cmd/caib/main.go
  • cmd/caib/runtime_wiring.go
  • internal/buildapi/server.go
  • internal/buildapi/types.go
  • internal/controller/imagebuild/controller.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • internal/controller/imagebuild/controller.go
  • cmd/caib/buildcmd/build.go
  • internal/buildapi/server.go
  • cmd/caib/flashcmd/flash.go
  • cmd/caib/image/image.go

📝 Walkthrough

Walkthrough

Adds a FlashCmd override that travels from CLI flags into BuildRequest/ImageBuild spec and is respected by the controller, which prefers the user-supplied FlashCmd over OperatorConfig defaults when preparing flash-related tasks.

Changes

Cohort / File(s) Summary
API Types
api/v1alpha1/imagebuild_types.go
Added FlashCmd string to FlashSpec; added GetFlashCmd() on ImageBuildSpec; GetFlashLeaseDuration() now returns DefaultFlashLeaseDuration when unset.
CLI / Command Options
cmd/caib/image/image.go, cmd/caib/buildcmd/build.go, cmd/caib/flashcmd/flash.go, cmd/caib/main.go
Introduced FlashCmd option (pointer/string) across image, build, and flash command option structs; added --flash-cmd flag wiring and package-level flashCmdOverride variable.
Runtime Wiring
cmd/caib/runtime_wiring.go
Added FlashCmd to runtimeState, initialized in newRuntimeState, and propagated into handler option construction for build/flash flows.
Build API
internal/buildapi/types.go, internal/buildapi/server.go
Added FlashCmd string to BuildRequest (json:"flashCmd,omitempty"); createBuild now populates FlashSpec.FlashCmd from the request; server resolves flashCmd via spec with fallback to mapping.
Controller
internal/controller/imagebuild/controller.go
Controller createBuildTaskRun/createFlashTaskRun now prefer imageBuild.Spec.GetFlashCmd() over OperatorConfig-derived flashCmd when non-empty (override applied before mapping validation).

Sequence Diagram(s)

sequenceDiagram
    participant User as CLI User
    participant CLI as caib CLI
    participant Server as Build API Server
    participant Controller as ImageBuild Controller
    participant Jumpstarter as Jumpstarter Flash

    User->>CLI: run command with --flash-cmd
    CLI->>Server: POST BuildRequest (FlashCmd)
    Server->>Server: create ImageBuild (FlashSpec.FlashCmd set)
    Server->>Controller: notify/create reconcile
    Controller->>Controller: read ImageBuild.Spec.GetFlashCmd()
    alt user FlashCmd present
        Controller->>Jumpstarter: invoke flash with user FlashCmd
    else no user FlashCmd
        Controller->>Jumpstarter: invoke flash with OperatorConfig FlashCmd
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • bkhizgiy

Poem

🐇 I hopped through flags and types today,
A FlashCmd found a brand new way,
From CLI paw to build and run,
The jumpstarter blinks — a job well done! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 --flash-cmd to override OperatorConfig' directly matches the main objective of the pull request and accurately summarizes the primary change across all modified files.

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

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/v1alpha1/imagebuild_types.go (1)

60-72: ⚠️ Potential issue | 🔴 Critical

Run make generate manifests to regenerate all artifacts after API type changes.

The CRD YAML includes flashCmd correctly, but the generated deepcopy file (api/v1alpha1/zz_generated.deepcopy.go) has not been updated to reflect the new FlashCmd field in FlashSpec. The DeepCopyInto() method shows only a shallow copy without explicit field handling for the new field. Per the coding guidelines, all generated artifacts must be refreshed whenever types in api/v1alpha1/ are modified.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/v1alpha1/imagebuild_types.go` around lines 60 - 72, The FlashSpec type
was updated with a new FlashCmd field but generated artifacts weren't
regenerated; run the project code generators (e.g., execute "make generate
manifests") to regenerate zz_generated.deepcopy.go and related CRD manifests so
DeepCopyInto/DeepCopy methods include proper handling of FlashCmd for the
FlashSpec struct; verify the regenerated zz_generated.deepcopy.go contains
explicit copying of FlashCmd in DeepCopyInto for FlashSpec and commit the
updated generated files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/buildapi/server.go`:
- Around line 1590-1594: getBuild currently ignores a persisted manual flash
override and reconstructs JumpstarterInfo.FlashCmd from the OperatorConfig
mapping; change the response construction in getBuild to prefer the persisted
value by using build.Spec.GetFlashCmd() (or equivalent accessor) before falling
back to the target/OperatorConfig mapping when setting JumpstarterInfo.FlashCmd,
ensuring builds created with --flash-cmd show the stored manual flash command in
API responses.

---

Outside diff comments:
In `@api/v1alpha1/imagebuild_types.go`:
- Around line 60-72: The FlashSpec type was updated with a new FlashCmd field
but generated artifacts weren't regenerated; run the project code generators
(e.g., execute "make generate manifests") to regenerate zz_generated.deepcopy.go
and related CRD manifests so DeepCopyInto/DeepCopy methods include proper
handling of FlashCmd for the FlashSpec struct; verify the regenerated
zz_generated.deepcopy.go contains explicit copying of FlashCmd in DeepCopyInto
for FlashSpec and commit the updated generated files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6306c39d-d342-4069-9847-89b6e723838b

📥 Commits

Reviewing files that changed from the base of the PR and between ca5efd5 and 783b405.

⛔ Files ignored due to path filters (1)
  • config/crd/bases/automotive.sdv.cloud.redhat.com_imagebuilds.yaml is excluded by !config/crd/bases/**
📒 Files selected for processing (9)
  • api/v1alpha1/imagebuild_types.go
  • cmd/caib/buildcmd/build.go
  • cmd/caib/flashcmd/flash.go
  • cmd/caib/image/image.go
  • cmd/caib/main.go
  • cmd/caib/runtime_wiring.go
  • internal/buildapi/server.go
  • internal/buildapi/types.go
  • internal/controller/imagebuild/controller.go

Comment thread internal/buildapi/server.go
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Assisted-by: claude-sonnet-4.6
@bennyz bennyz force-pushed the custom-flash-command branch from 783b405 to bf1c422 Compare March 10, 2026 17:11
@bennyz bennyz requested a review from bkhizgiy March 10, 2026 18:26
@bennyz bennyz merged commit 34cd4bc into centos-automotive-suite:main Mar 10, 2026
4 checks passed
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