Skip to content

improvements: Use pre-built binary versions for developer binaries - #326

Merged
SpaceFace02 merged 1 commit into
trusted-execution-clusters:mainfrom
SpaceFace02:prebuilt-components
Aug 5, 2026
Merged

improvements: Use pre-built binary versions for developer binaries#326
SpaceFace02 merged 1 commit into
trusted-execution-clusters:mainfrom
SpaceFace02:prebuilt-components

Conversation

@SpaceFace02

@SpaceFace02 SpaceFace02 commented Aug 4, 2026

Copy link
Copy Markdown
Member

integration tests run make crds-rs. We can simplify the makefile to use prebuilt versions of developer tools like yq, kopium and controller-gen, then having go install as fallback, if URLS change.

Summary by Sourcery

Use prebuilt, architecture-aware binaries for controller-gen, yq, and kopium in the Makefile, with go/cargo installation as a fallback when downloads fail.

Enhancements:

  • Download prebuilt controller-gen, yq, and kopium binaries during build-tool setup with architecture-aware URLs and chmod.
  • Fallback to go/cargo installation when prebuilt developer binaries cannot be fetched.
  • Introduce OS and architecture autodetection in the Makefile to drive selection of appropriate prebuilt tooling artifacts.

@SpaceFace02 SpaceFace02 self-assigned this Aug 4, 2026
@sourcery-ai

sourcery-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR updates the Makefile to prefer downloading prebuilt binaries for controller-gen, yq, and kopium based on detected OS/architecture, with go/cargo installation kept as a fallback, and introduces OS/ARCH detection helpers and a simplification to the go-install-tool macro.

Flow diagram for developer tool binary installation in Makefile

flowchart TD
  A[make build-tools / yq / kopium] --> B[detect OS]
  B --> C[detect ARCH]
  C --> D{tool target}
  D -->|controller-gen| E[run curl for controller-gen prebuilt]
  D -->|yq| F[run curl for yq prebuilt]
  D -->|kopium| G[run curl for kopium prebuilt]

  E --> H{curl success?}
  F --> I{curl success?}
  G --> J{curl success?}

  H -->|yes| K[chmod +x controller-gen]
  I -->|yes| L[chmod +x yq]
  G -->|yes| M[mv kopium into LOCALBIN]

  H -->|no| N[go-install-tool]
  I -->|no| N
  J -->|no| O[cargo-install-tool]

  K --> P[tool ready]
  L --> P
  M --> P
  N --> P
  O --> P
Loading

File-Level Changes

Change Details Files
Detect OS/CPU architecture and derive a kopium Rust target triple for use with prebuilt binaries.
  • Introduce OS variable derived from uname -s and normalized to lowercase.
  • Introduce ARCH variable derived from uname -m, mapping x86_64→amd64 and aarch64→arm64.
  • Add KOPIUM_RUST_ARCH and KOPIUM_TARGET variables that compute the appropriate Rust target triple for Linux and macOS.
Makefile
Prefer downloading prebuilt controller-gen, yq, and kopium binaries with curl and chmod/mv, falling back to existing go/cargo install macros on failure.
  • Change controller-gen rule to curl a versioned binary from GitHub using OS/ARCH into LOCALBIN and chmod +x, with go-install-tool as a fallback via shell OR.
  • Change yq rule to download the appropriate yq_$(OS)_$(ARCH) binary, chmod +x, and fall back to go-install-tool if download fails.
  • Change kopium rule to download and extract a versioned tar.xz archive for KOPIUM_TARGET into LOCALBIN, then move the kopium binary into the expected path, with cargo-install-tool as a fallback.
  • Wrap kopium download/extract/move in a grouped command block so the OR fallback only triggers when the whole sequence fails.
Makefile
Simplify the go-install-tool helper macro by removing an unused intermediate package variable.
  • Remove the unused package=$(3)@$(4) assignment from the go-install-tool macro body while keeping behavior otherwise unchanged.
Makefile

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 KOPIUM_RUST_ARCH := $(shell uname -m) logic will produce arm64 on Apple Silicon, but kopium release artifacts use aarch64-apple-darwin, so the computed KOPIUM_TARGET will be invalid on macOS ARM; consider normalizing arm64 to aarch64 there as you did for ARCH.
  • For non-Linux/macOS platforms KOPIUM_TARGET will be empty and the curl URL will be malformed; it might be better to fail early with a clear error or skip the prebuilt path when KOPIUM_TARGET is undefined instead of attempting a broken download.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `KOPIUM_RUST_ARCH := $(shell uname -m)` logic will produce `arm64` on Apple Silicon, but kopium release artifacts use `aarch64-apple-darwin`, so the computed `KOPIUM_TARGET` will be invalid on macOS ARM; consider normalizing `arm64` to `aarch64` there as you did for `ARCH`.
- For non-Linux/macOS platforms `KOPIUM_TARGET` will be empty and the curl URL will be malformed; it might be better to fail early with a clear error or skip the prebuilt path when `KOPIUM_TARGET` is undefined instead of attempting a broken download.

## Individual Comments

### Comment 1
<location path="Makefile" line_range="22-27" />
<code_context>
+# either x86_64/amd64 or aarch64/arm64
+ARCH ?= $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
+
+# Kopium architecture detection: supports only Linux and macOS.
+KOPIUM_RUST_ARCH := $(shell uname -m)
+ifeq ($(OS),linux)
+  KOPIUM_TARGET := $(KOPIUM_RUST_ARCH)-unknown-linux-gnu
+else ifeq ($(OS),darwin)
+  KOPIUM_TARGET := $(KOPIUM_RUST_ARCH)-apple-darwin
+endif
+
</code_context>
<issue_to_address>
**issue (bug_risk):** KOPIUM_TARGET is incorrect for Apple Silicon (arm64) Rust target triples

On Apple Silicon, `uname -m` returns `arm64`, but the Rust target triple is `aarch64-apple-darwin`. This makes `KOPIUM_TARGET := $(KOPIUM_RUST_ARCH)-apple-darwin` resolve to `arm64-apple-darwin`, which is invalid and will break Kopium downloads on macOS ARM.

Please normalize `KOPIUM_RUST_ARCH` (or reuse `ARCH`) so that `arm64` is mapped to `aarch64`, producing `aarch64-apple-darwin` for Apple Silicon.
</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 Makefile
…hen fallback to go install

Signed-off-by: Chirag Rao <crao@redhat.com>
@SpaceFace02
SpaceFace02 force-pushed the prebuilt-components branch from c783ce9 to 2571096 Compare August 4, 2026 11:40
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Jakob-Naucke, SpaceFace02

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@SpaceFace02
SpaceFace02 merged commit 1e82f12 into trusted-execution-clusters:main Aug 5, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants