feat: stamp version/gitCommit/buildDate into manager binary#147
Merged
Conversation
Standard kubebuilder pattern. Linker injects build metadata into package-level vars in cmd/manager; the values are logged once at startup so triage can identify exactly which image is running. - cmd/manager/main.go: declare version/gitCommit/buildDate vars, log them after zap is configured. - Dockerfile: accept VERSION, GIT_COMMIT, BUILD_DATE build args and pass them through -ldflags to go build. - .github/workflows/build-and-scan.yaml: pass docker meta version, github.sha and an ISO-8601 build date as build args.
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.
Summary
version,gitCommit,buildDatevars incmd/manager/main.go, populated at link time via-ldflags "-X main.<var>=..."pr-135rebuilds)DockerfileacceptsVERSION,GIT_COMMIT,BUILD_DATEbuild args and threads them into both the regular and coverage buildsbuild-and-scan.yamlpassesdocker/metadata-actionversion,github.shaand an ISO-8601 build date as docker build argsExample log line
Test plan
go build -ldflags "-X main.version=test ..." ./cmd/managersucceeds and stamps the valueskubectl logs ...shows the stamped valuesFollow-ups
/versionvia the existing health-probe listener and a--versionCLI flag if scrapeable build info is wanted — out of scope for this PR.