-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.
Description
What broke? What's expected?
When using go build, go install and go run, some fields in the version subcommand output are not updated.
Currently, the ldflags are only injected in the binary when running make build and goreleaser build, leaving the fields KubeBuilderVersion, GitCommit, BuildDate, GoOs and GoArch empty, which can make it difficult for users to report bugs if they installed the binaries using the go toolchain.
Reproducing this issue
When running the full build step we populate all the fields:
$ goreleaser build --config=./build/.goreleaser.yml
$ ./dist/kubebuilder_linux_amd64_v1/kubebuilder version
Version: cmd.version{KubeBuilderVersion:"4.10.1", KubernetesVendor:"1.34.1", GitCommit:"8bce950e46b914d54c872da25500b8c27b6c05e8", BuildDate:"2025-12-27T20:29:19Z", GoOs:"linux", GoArch:"amd64"}
$ make build
$ ./bin/kubebuilder version
Version: cmd.version{KubeBuilderVersion:"v4.10.1", KubernetesVendor:"1.34.1", GitCommit:"8bce950e46b914d54c872da25500b8c27b6c05e8", BuildDate:"2025-12-27T20:29:58Z", GoOs:"linux", GoArch:"amd64"}
Building with the go toolchain methods leave fields unset:
$ go build .
$ ./kubebuilder version
Version: cmd.version{KubeBuilderVersion:"(devel)", KubernetesVendor:"1.34.1", GitCommit:"$Format:%H$", BuildDate:"1970-01-01T00:00:00Z", GoOs:"unknown", GoArch:"unknown"}
$ go install .
$ kubebuilder version
Version: cmd.version{KubeBuilderVersion:"(devel)", KubernetesVendor:"1.34.1", GitCommit:"$Format:%H$", BuildDate:"1970-01-01T00:00:00Z", GoOs:"unknown", GoArch:"unknown"}
$ go run ./main.go version
Version: cmd.version{KubeBuilderVersion:"(devel)", KubernetesVendor:"1.34.1", GitCommit:"$Format:%H$", BuildDate:"1970-01-01T00:00:00Z", GoOs:"unknown", GoArch:"unknown"}
KubeBuilder (CLI) Version
Version: cmd.version{KubeBuilderVersion:"4.10.1", KubernetesVendor:"1.34.1", GitCommit:"8bce950e46b914d54c872da25500b8c27b6c05e8", BuildDate:"2025-12-27T20:29:19Z", GoOs:"linux", GoArch:"amd64"}
PROJECT version
No response
Plugin versions
Other versions
No response
Extra Labels
No response
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.