Fix/version stamping#82
Open
Davanum Srinivas (dims) wants to merge 1 commit into
Open
Conversation
Davanum Srinivas (dims)
added a commit
to dims/substrate
that referenced
this pull request
May 26, 2026
Per review feedback on PR agent-substrate#82: the version package is consumed only by substrate's own binaries, so it belongs under internal/ where the Go toolchain enforces that nothing outside the module can import it. Pure rename + import-path update; no behavioural change. Verified kubectl-ate --version still prints the expected line and linux servers still build with -ldflags. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Davanum Srinivas (dims)
added a commit
to dims/substrate
that referenced
this pull request
May 26, 2026
Per review feedback on PR agent-substrate#82: the version package is consumed only by substrate's own binaries, so it belongs under internal/ where the Go toolchain enforces that nothing outside the module can import it. Pure rename + import-path update; no behavioural change. Verified kubectl-ate --version still prints the expected line and linux servers still build with -ldflags. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
430a85b to
9ebcdca
Compare
Davanum Srinivas (dims)
added a commit
to dims/substrate
that referenced
this pull request
May 26, 2026
Two CI failures on PR agent-substrate#82: 1. run-tests: gofmt reordered the internal/version import in cmd/ateapi/main.go (alphabetical within the substrate import group). 2. e2e-test: hack/install-ate.sh's run_ko wrapper passed --ldflags unconditionally, but the pinned ko version rejects that flag on ko apply. Guard the injection with a case statement so --ldflags only goes on build / publish / resolve. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
13cd712 to
3b0a0d5
Compare
Adds internal/version with three vars (Version, Commit, BuildDate) set
via -ldflags -X at build time. When unset (e.g. plain `go build`
without LDFLAGS), runtime/debug.ReadBuildInfo() populates them from the
embedded vcs info so `go install`, `go run`, and ko-built images
(buildvcs is on by default) still produce something meaningful.
Wired through:
- Makefile: VERSION / COMMIT / BUILD_DATE resolved from `git describe`
/ `git rev-parse` / `date`. LDFLAGS plumbed into every go-build and
ko-build target (build-images, build-atectl, build-atenet,
build-demos).
- hack/install-ate.sh: untouched here — ko apply / resolve don't
accept --ldflags, and ko's buildvcs embedding gives Commit +
BuildDate automatically through runtime/debug.ReadBuildInfo() in
the version package's init() fallback.
All six binaries respond to `--version`:
- kubectl-ate and atenet (cobra): rootCmd.Version = version.String()
- ateapi, atelet, ateom-gvisor, podcertcontroller (flag): explicit
`-version` bool that prints and exits.
Sample output:
kubectl-ate version 3b0a0d5 commit=3b0a0d5c2... \
built=2026-05-26T14:16:53Z darwin/arm64
Closes the "kubectl-ate --version has nothing to print" gap; gives ops
a way to tell at a glance which commit a deployed substrate component
came from.
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
3b0a0d5 to
87530bd
Compare
Collaborator
For a greenfield effort, did we consider https://pkg.go.dev/runtime/debug#BuildInfo instead of depending on ldflags? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a pkg/version package and wires -ldflags -X through the Makefile + hack/install-ate.sh. All six binaries (kubectl-ate, atenet, ateapi, atelet, ateom-gvisor, podcertcontroller) now respond to --version and print something!
Please share what you think ... exactly we should print :)
Fixes #<issue_number_goes_here>