Skip to content

feat: stamp version/gitCommit/buildDate into manager binary#147

Merged
peter-svensson merged 1 commit into
mainfrom
feat/version-banner
May 7, 2026
Merged

feat: stamp version/gitCommit/buildDate into manager binary#147
peter-svensson merged 1 commit into
mainfrom
feat/version-banner

Conversation

@peter-svensson
Copy link
Copy Markdown
Member

Summary

  • Adds package-level version, gitCommit, buildDate vars in cmd/manager/main.go, populated at link time via -ldflags "-X main.<var>=..."
  • Logs them once at startup so triage can confirm which image is running (raised in feat!: pluggable secrets/connection backends (k8s, infisical, aws) #135 review while debugging the GRANT issue across two near-identical pr-135 rebuilds)
  • Dockerfile accepts VERSION, GIT_COMMIT, BUILD_DATE build args and threads them into both the regular and coverage builds
  • build-and-scan.yaml passes docker/metadata-action version, github.sha and an ISO-8601 build date as docker build args

Example log line

{"level":"info","msg":"starting database-user-operator","version":"pr-145","gitCommit":"8567361...","buildDate":"2026-05-07T11:40:00Z"}

Test plan

  • go build -ldflags "-X main.version=test ..." ./cmd/manager succeeds and stamps the values
  • CI builds the image and the version banner shows the PR-derived metadata
  • Pull the resulting image and confirm kubectl logs ... shows the stamped values

Follow-ups

  • Could expose /version via the existing health-probe listener and a --version CLI flag if scrapeable build info is wanted — out of scope for this PR.

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.
@peter-svensson peter-svensson requested a review from argoyle as a code owner May 7, 2026 09:39
@opzkit-auto-merge opzkit-auto-merge Bot enabled auto-merge (squash) May 7, 2026 09:39
@peter-svensson peter-svensson disabled auto-merge May 7, 2026 09:56
@peter-svensson peter-svensson merged commit 30d873e into main May 7, 2026
8 checks passed
@peter-svensson peter-svensson deleted the feat/version-banner branch May 7, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant