Use ART-injected env vars for version in Konflux builds#186
Conversation
ART/doozer injects BUILD_VERSION and SOURCE_GIT_COMMIT as ENV vars in Konflux builds before the RUN step executes. Use these directly instead of ARG-based version passing, which collided with Konflux-injected VERSION (the Go toolchain version). Falls back to "dev"/"unknown" for local builds where ART env vars are not present. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe konflux.Dockerfile transitions from static build arguments ( ChangesBuild Variable Injection & Metadata Embedding
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
konflux.Dockerfile (1)
29-33: 💤 Low valueConsider quoting the
-Xflag values to guard against whitespace in version strings.Both
${OADP_VERSION}and${OADP_GIT_COMMIT}are embedded unquoted inside the outer-ldflags="…"string. IfBUILD_VERSIONever contains a space (e.g., a pre-release tag like1.6.0 rc1), the shell would split the word andgo buildwould see a malformed extra flag. ART-injected values are well-controlled so the actual risk is very low, but quoting the value half of each-Xassignment is the idiomatic defensive form:🛡️ Defensive quoting for -X ldflag values
- -ldflags="-s -w \ - -X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=${OADP_VERSION} \ - -X github.com/vmware-tanzu/velero/pkg/buildinfo.GitSHA=${OADP_GIT_COMMIT} \ - -X github.com/vmware-tanzu/velero/pkg/buildinfo.GitTreeState=clean" \ + -ldflags="-s -w \ + -X 'github.com/vmware-tanzu/velero/pkg/buildinfo.Version=${OADP_VERSION}' \ + -X 'github.com/vmware-tanzu/velero/pkg/buildinfo.GitSHA=${OADP_GIT_COMMIT}' \ + -X 'github.com/vmware-tanzu/velero/pkg/buildinfo.GitTreeState=clean'" \🤖 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 29 - 33, The -ldflags -X assignments for buildinfo.Version and buildinfo.GitSHA are unquoted and can break if OADP_VERSION or OADP_GIT_COMMIT contain whitespace; update the go build invocation (the -ldflags string in the Docker build step) so each -X assignment quotes its right-hand value (the assignments for github.com/vmware-tanzu/velero/pkg/buildinfo.Version and github.com/vmware-tanzu/velero/pkg/buildinfo.GitSHA) to prevent shell splitting or malformed flags.
🤖 Prompt for all review comments with 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.
Nitpick comments:
In `@konflux.Dockerfile`:
- Around line 29-33: The -ldflags -X assignments for buildinfo.Version and
buildinfo.GitSHA are unquoted and can break if OADP_VERSION or OADP_GIT_COMMIT
contain whitespace; update the go build invocation (the -ldflags string in the
Docker build step) so each -X assignment quotes its right-hand value (the
assignments for github.com/vmware-tanzu/velero/pkg/buildinfo.Version and
github.com/vmware-tanzu/velero/pkg/buildinfo.GitSHA) to prevent shell splitting
or malformed flags.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Joeavaikath, shubham-pampattiwar, weshayutin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherry-pick oadp-1.6 |
|
@Joeavaikath: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@Joeavaikath: #186 failed to apply on top of branch "oadp-1.6": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Use ART-injected env vars for version in Konflux builds
Summary
BUILD_VERSION,SOURCE_GIT_COMMIT, and other env vars into the builder stage before ourRUNstep executesARG VERSION=devwhich collided with the Konflux-injectedVERSION(the Go toolchain version from the builder image), causingoc oadp versionto reportVersion: 1.25instead of the OADP versionBUILD_VERSIONandSOURCE_GIT_COMMITdirectly from the ART-injected env varsdev/unknownfor local builds where ART env vars are not presentART env vars used
BUILD_VERSION1.6.0)SOURCE_GIT_COMMITbuildinfo.GitSHATest plan
oc oadp versionshows1.6.0, not1.25)podman build -f konflux.Dockerfile .still works (falls back todev)🤖 Generated with Claude Code
Summary by CodeRabbit