Skip to content

Add option target imgref#50

Merged
alicefr merged 3 commits into
mainfrom
target-imgref
Jun 8, 2026
Merged

Add option target imgref#50
alicefr merged 3 commits into
mainfrom
target-imgref

Conversation

@alicefr

@alicefr alicefr commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Overwrite the reported bootc image. In this way, we can reference the image from the local registry.

Fixes: #45

Summary by Sourcery

Add support for overriding the bootc image reference tracked by cluster nodes via a new CLI option and propagate it through node configuration and initialization.

New Features:

  • Introduce a --target-imgref option to 'cluster start' and 'node add' commands to override the bootc image reference recorded by the VM.
  • Propagate the configured target image reference into node configuration and cloud-init so the origin file reflects the overridden image reference.

Tests:

  • Extend the cluster lifecycle integration test to start a cluster with a target image reference and verify bootc status reports the overridden image reference.

alicefr added 3 commits June 4, 2026 14:30
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a new optional --target-imgref flag for cluster and node creation to override the bootc-tracked image reference inside the VM, wires it through Node and cloud-init data, and validates it via an integration test that checks bootc status.

Sequence diagram for applying TargetImgRef inside VM via cloud-init

sequenceDiagram
    participant User
    participant StartCmd
    participant Node
    participant CloudInit
    participant bootc

    User->>StartCmd: bink cluster start --target-imgref VALUE
    StartCmd->>Node: WithTargetImgRef(targetImgRef)
    Node->>Node: newCloudInitData(sshPubKey)
    Node->>CloudInit: render user-data.yaml.tmpl (TargetImgRef)
    CloudInit->>CloudInit: [TargetImgRef not empty]
    CloudInit->>bootc: bootc status --json
    bootc-->>CloudInit: deploySerial, checksum
    CloudInit->>CloudInit: sed container-image-reference=ostree-unverified-registry:TargetImgRef
Loading

File-Level Changes

Change Details Files
Introduce --target-imgref option to cluster start and node add commands and propagate it into node creation.
  • Add target-imgref string flag to bink cluster start and plumb it into runStart parameters.
  • Add target-imgref string flag to bink node add and plumb it into runAdd parameters.
  • Update runStart and runAdd to pass targetImgRef into node options via node.WithTargetImgRef.
internal/cli/cluster/start.go
internal/cli/node/add.go
Extend Node and CloudInit data model to carry target image reference into the guest.
  • Add TargetImgRef field to Node struct and a NodeOption constructor WithTargetImgRef.
  • Extend CloudInitData with TargetImgRef and populate it from Node.TargetImgRef in newCloudInitData.
internal/node/node.go
internal/node/cloudinit.go
Modify cloud-init user-data template to override bootc origin file when a target image reference is provided.
  • Wrap new commands in a conditional block that runs only when TargetImgRef is set.
  • Remount /sysroot as read-write, derive deploySerial and checksum from bootc status JSON, compute ORIGIN path, and sed the container-image-reference line to use ostree-unverified-registry:{{.TargetImgRef}}.
internal/node/templates/user-data.yaml.tmpl
Add integration coverage to ensure target-imgref is honored and reflected in bootc status.
  • Define a targetImgRef value in the cluster lifecycle test and pass --target-imgref to bink cluster start.
  • Add an assertion that bootc status inside the node contains the target image reference.
test/integration/cluster_test.go

Assessment against linked issues

Issue Objective Addressed Explanation
https://github.com/alicefr/bink/issues/45 Add a --target-imgref flag to bink cluster start and bink node add, and plumb its value through the CLI, node configuration, and cloud-init data.
https://github.com/alicefr/bink/issues/45 Update cloud-init configuration to modify the bootc origin file so that the VM tracks the image reference passed via --target-imgref.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue, and left some high level feedback:

  • The sed line in user-data.yaml.tmpl directly embeds {{.TargetImgRef}} into a single-quoted script, which will break if the image reference ever contains a single quote; consider escaping the value or using double quotes + proper shell escaping to make this robust.
  • In the cloud-init runcmd snippet you invoke bootc status --json twice with jq; you could run it once and reuse the parsed JSON or at least the shell variable to reduce duplication and potential inconsistencies.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `sed` line in `user-data.yaml.tmpl` directly embeds `{{.TargetImgRef}}` into a single-quoted script, which will break if the image reference ever contains a single quote; consider escaping the value or using double quotes + proper shell escaping to make this robust.
- In the cloud-init `runcmd` snippet you invoke `bootc status --json` twice with `jq`; you could run it once and reuse the parsed JSON or at least the shell variable to reduce duplication and potential inconsistencies.

## Individual Comments

### Comment 1
<location path="internal/node/templates/user-data.yaml.tmpl" line_range="91-92" />
<code_context>
+{{- if .TargetImgRef}}
+  - |
+    mount -o remount,rw /sysroot
+    DEPLOY_PATH=$(bootc status --json | jq -r '.status.booted.ostree.deploySerial // empty')
+    CHECKSUM=$(bootc status --json | jq -r '.status.booted.ostree.checksum')
+    ORIGIN="/ostree/deploy/default/deploy/${CHECKSUM}.${DEPLOY_PATH}.origin"
+    sed -i 's|^container-image-reference=.*|container-image-reference=ostree-unverified-registry:{{.TargetImgRef}}|' "$ORIGIN"
</code_context>
<issue_to_address>
**suggestion (performance):** bootc status is invoked twice; capturing it once would be simpler and avoid redundant work.

Consider running `bootc status --json` once (e.g., `STATUS=$(bootc status --json)`) and deriving both `DEPLOY_PATH` and `CHECKSUM` from that variable. This avoids duplicate work and guarantees both values come from the same status snapshot.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread internal/node/templates/user-data.yaml.tmpl
@alicefr
alicefr merged commit fdfdc86 into main Jun 8, 2026
5 of 9 checks passed
@alicefr
alicefr deleted the target-imgref branch June 18, 2026 10:20
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.

Add --target-imgref to bink cluster start and bink node add

1 participant