Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func NewVersionCommand(f *flags.GlobalFlags) *cobra.Command {
func (o *Options) run() error {
fmt.Println("crane:")
fmt.Printf("\tVersion: %s\n", buildinfo.Version)
fmt.Printf("\tSHA: %s\n", buildinfo.BuildCommit)
fmt.Println("crane-lib:")
fmt.Printf("\tVersion: %s\n", buildinfo.CranelibVersion)
return nil
Expand Down
3 changes: 3 additions & 0 deletions internal/buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import (
)

var (
// Version and BuildCommit can be overridden at build time with:
// go build -ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=<version> -X github.com/konveyor/crane/internal/buildinfo.BuildCommit=$(git rev-parse HEAD)"
Version string = "v0.0.6"

CranelibVersion string = cranelibversion.Version
BuildCommit string = ""
)
56 changes: 56 additions & 0 deletions konflux.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM registry.redhat.io/ubi9/go-toolset:1.25 AS builder

COPY . /workspace
WORKDIR /workspace

ARG TARGETOS=linux
ARG TARGETARCH=amd64

RUN set -e && \
# Prefer ART/Konflux injected env vars; fall back for local builds.
MTA_OPS_VERSION="${BUILD_VERSION:-dev}" && \
MTA_OPS_GIT_COMMIT="${SOURCE_GIT_COMMIT:-unknown}" && \
Comment on lines +11 to +12

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 | 🟠 Major | ⚡ Quick win

Build metadata args are used but never declared.

Line 11/12 and Line 32 read BUILD_VERSION / SOURCE_GIT_COMMIT, but those args are not declared via ARG, so injected build-args won’t be available and the build falls back to dev/unknown.

Suggested fix
 FROM registry.redhat.io/ubi9/go-toolset:1.25 AS builder

 COPY . /workspace
 WORKDIR /workspace

+ARG BUILD_VERSION=dev
+ARG SOURCE_GIT_COMMIT=unknown
 ARG TARGETOS=linux
 ARG TARGETARCH=amd64

 RUN set -e && \
-    MTA_OPS_VERSION="${BUILD_VERSION:-dev}" && \
-    MTA_OPS_GIT_COMMIT="${SOURCE_GIT_COMMIT:-unknown}" && \
+    MTA_OPS_VERSION="${BUILD_VERSION}" && \
+    MTA_OPS_GIT_COMMIT="${SOURCE_GIT_COMMIT}" && \

Also applies to: 32-35

🤖 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 `@konflux.Dockerfile` around lines 11 - 12, The Dockerfile uses BUILD_VERSION
and SOURCE_GIT_COMMIT when setting MTA_OPS_VERSION and MTA_OPS_GIT_COMMIT but
never declares them as build args; add ARG declarations for BUILD_VERSION and
SOURCE_GIT_COMMIT (with sensible defaults if desired) before they are referenced
so injected --build-arg values are available, and mirror the same ARG additions
for the later occurrences around where MTA_OPS_* are set (the blocks referencing
BUILD_VERSION / SOURCE_GIT_COMMIT on lines near 32-35) to ensure both build
stages receive the variables.

mkdir -p /tmp/archives /tmp/bin && \
for platform in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do \
os=$(echo "$platform" | cut -d'/' -f1) && \
arch=$(echo "$platform" | cut -d'/' -f2) && \
if [ "$os" = "windows" ]; then \
output="mta-ops_${os}_${arch}.exe"; \
else \
output="mta-ops_${os}_${arch}"; \
fi && \
echo "Building standalone binary $output (version=${MTA_OPS_VERSION}, commit=${MTA_OPS_GIT_COMMIT})..." && \
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath -mod=readonly \
-ldflags="-X github.com/konveyor/crane/internal/buildinfo.Version=${MTA_OPS_VERSION} -X github.com/konveyor/crane/internal/buildinfo.BuildCommit=${MTA_OPS_GIT_COMMIT}" \
-o "/tmp/archives/$output" ./main.go && \
(cd /tmp/archives && sha256sum "$output" > "$output.sha256"); \
done && \
if [ "${TARGETOS}" = "windows" ]; then \
runtime_output="mta-ops_${TARGETOS}_${TARGETARCH}.exe"; \
else \
runtime_output="mta-ops_${TARGETOS}_${TARGETARCH}"; \
fi && \
cp "/tmp/archives/${runtime_output}" /tmp/bin/mta-ops && \
cp LICENSE /tmp/archives/LICENSE && \
go clean -cache -modcache -testcache && \
rm -rf /opt/app-root/src/.cache /opt/app-root/src/go/pkg /tmp/go /tmp/.cache

FROM registry.access.redhat.com/ubi9:latest

RUN dnf -y install openssl && dnf -y reinstall tzdata && dnf clean all

COPY --from=builder /tmp/archives /archives
COPY --from=builder /tmp/bin/mta-ops /usr/local/bin/mta-ops
COPY LICENSE /licenses/

USER 1001

ENTRYPOINT ["/usr/local/bin/mta-ops"]

LABEL \
description="MTA-Ops CLI for Kubernetes migration workflows" \
io.k8s.description="MTA-Ops CLI for Kubernetes migration workflows" \
io.k8s.display-name="MTA-Ops CLI" \
io.openshift.maintainer.project="MTA-Ops" \
io.openshift.tags="migration,modernization,konveyor,mta-ops" \
summary="MTA-Ops CLI"
Loading