feat(go-lib/version): add Handler and HandlerFor http.Handler#270
Open
priyaselvaganesan wants to merge 2 commits into
Open
feat(go-lib/version): add Handler and HandlerFor http.Handler#270priyaselvaganesan wants to merge 2 commits into
priyaselvaganesan wants to merge 2 commits into
Conversation
Adds a shared HTTP handler to go-lib/pkg/version that serves build
metadata as JSON at GET /version. Version and commit are injected at
link time via Bazel x_defs (STABLE_VERSION, STABLE_GIT_COMMIT) when
built with --stamp. Falls back to Go runtime build info for commit
when GitHash is not injected, so local go build still returns a real
commit SHA.
Response schema: {"version": "v1.2.3", "commit": "abc1234"}
Refs: NVCF-10975
🛡️ CodeQL Analysis🚨 Found 2 issue(s) Severity Breakdown:
📋 Top Issues🔗 View full details in Security tab 🕐 Last updated: 2026-07-20 19:00:38 UTC | Commit: f779787 |
shelleyshen-0
approved these changes
Jul 20, 2026
4 tasks
kristinapathak
requested changes
Jul 21, 2026
kristinapathak
left a comment
Contributor
There was a problem hiding this comment.
Please provide a github issue rather than an internal JIRA issue.
Contributor
Author
Done — created issue #315 and updated the Issues section here. |
Adds Service string var injected via x_defs so each service identifies
itself in the response. Renames from GET /version to GET /info following
reviewer feedback that /info is more extensible for future fields.
Response schema: {"service":"nvcf-my-service","version":"v1.2.3","commit":"abc1234"}
Refs: NVCF-10975
priyaselvaganesan
added a commit
that referenced
this pull request
Jul 21, 2026
Registers nvcfversion.Handler() at GET /info on the management server (port 8082). Returns service name, semver, and commit SHA injected at build time via Bazel x_defs. Blocked on go-lib PR #270 merging. Once that lands, go.mod will be updated to the published version that includes Handler(). Refs: NVCF-10975
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.
TL;DR
Adds
Handler()andHandlerFor()togo-lib/pkg/version— a shared HTTP handler that serves build metadata as JSON atGET /info. Each service registers one line to expose the endpoint; service name, version, and commit are injected via Bazelx_defsat build time.Additional Details
Handler()reads theService,Version, andGitHashpackage vars injected at link time viax_defs(set to a hardcoded service name,{STABLE_VERSION}, and{STABLE_GIT_COMMIT}fromtools/workspace_status.shwhen building with--stamp).HandlerFor()accepts explicit(service, ver, commit)values and falls back to Go runtime build info for commit when the value is empty, sogo buildlocally returns a real commit SHA. Empty service or version fall back to"unknown".Response schema:
{"service":"nvcf-my-service","version":"v1.2.3","commit":"abc1234"}This is a prerequisite for the follow-on PR that wires
nvcfversion.Handler()into each Go control plane service.For the Reviewer
handler.goandhandler_test.goare new files;BUILD.bazeladds them to the existinggo_libraryandgo_testtargets.version.gois updated to add aServicepackage var alongside the existingVersion,GitHash, andDirtyvars.For QA
go test ./pkg/version/...passes. No service changes in this PR.Issues
Relates to #315
Checklist