feat(build-time-versioning): apiserver -version flag and startup log

Declares GitCommit/BuildTime package vars (default "unknown", target of
task 4.1's -ldflags -X injection), a -version flag checked before
utils.PromptForTopDir()/InitLogger() (zero filesystem side effects), and
extends the existing "Initialize Logger done!" startup log line with
zap.String structured fields carrying both values, per design.md's
explicit mandate.

Live-verified end to end: -version output and the startup log's first
line are byte-identical, with a real commit id (matching
git rev-parse --short HEAD plus dirty suffix) and UTC timestamp -- the
first full round-trip proof in this spec (earlier Go tasks could only
verify via linked build-info metadata, since no consuming vars existed
yet).

Task 4.4/13 of build-time-versioning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-20 13:47:03 +00:00
parent 45c9b026f3
commit 17e837b196
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 29 additions and 6 deletions

View file

@ -73,11 +73,10 @@
- _Boundary: Makefile_
- _Depends: 4.1_
- [ ] 4.4 (P) apiserver: version flag, vars, and startup log
- Declare `GitCommit`/`BuildTime` package vars (default `unknown`) in `src/frontend/apiserver/cmd/main.go`
- Add a `-version` flag, checked before `utils.InitLogger()`, that prints both values and exits with no logging side effects
- Extend the existing `logger.Info("********** Initialize Logger done!")` call site to also log both values
- Observable: `xce_apiserver -version` prints both values and exits without starting the server; the startup log's first lines include the identical two values
- [x] 4.4 (P) apiserver: version flag, vars, and startup log
- `GitCommit`/`BuildTime` package vars (default `unknown`); `-version` flag checked before `utils.PromptForTopDir`/`utils.InitLogger()`, zero filesystem side effects (live-verified: no logs dir created)
- Startup log extended via `zap.String("gitCommit", ...)`/`zap.String("buildTime", ...)` structured fields on the existing `"Initialize Logger done!"` line, per design.md's explicit mandate
- Observable confirmed live (independently re-verified by review, full round trip): `-version` and the startup log's first line are byte-identical (`45c9b026-dirty`, matching `git rev-parse --short HEAD` + dirty suffix, and a real UTC timestamp)
- _Requirements: 1.1, 1.2, 2.1, 2.2, 3.1, 3.2_
- _Boundary: apiserver/cmd/main.go_
- _Depends: 4.1_