feat: add /version endpoint and global Minder-Version header#6358
Open
DharunMR wants to merge 1 commit intomindersec:mainfrom
Open
feat: add /version endpoint and global Minder-Version header#6358DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR wants to merge 1 commit intomindersec:mainfrom
Conversation
c44ed8f to
a1bff3a
Compare
a1bff3a to
4ade151
Compare
| func VersionHeaderInterceptor() grpc.UnaryServerInterceptor { | ||
| return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { | ||
| // SetHeader tells gRPC-Gateway to add this to the HTTP response | ||
| _ = grpc.SetHeader(ctx, metadata.Pairs("x-minder-version", constants.CLIVersion)) |
Member
There was a problem hiding this comment.
RFC 6648 deprecates the "X-" prefix on headers, so just call this either "minder-version" or "server" (a standard header). If you use server, you might want to include the string "Minder" before the version.
Member
There was a problem hiding this comment.
In fact, constants.ServerUserAgent might be exactly what you want.
Note that constants.CLIVersion only appears to be set via ldflags for CLI builds, not for the server. The Makefile and GitHub Actions is probably the right place to do this if you want to; you'll need to use GOFLAGS per https://ko.build/advanced/faq/#how-can-i-set-ldflags
Contributor
Author
4ade151 to
5967607
Compare
Signed-off-by: DharunMR <maddharun56@gmail.com>
5967607 to
15b9407
Compare
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
This PR addresses the need to easily expose the Minder server's build version and commit hash for tooling and debugging purposes, as requested. It introduces a dedicated, unauthenticated
/api/v1/versionendpoint and adds a global gRPC Unary Interceptor to stamp the server version on all incoming HTTP/gRPC responses.Changes Included
GetVersionRPC toHealthServicemapped toGET /api/v1/version. Configuredrpc_optionsto allow unauthenticated access (TARGET_RESOURCE_NONE).GetVersionlogic to returnconstants.CLIVersionandconstants.Revision.VersionHeaderInterceptorto inject theMinder-Versionheader into the response metadata for all requests."v0.1.0"service version ininitMetricswith the dynamicconstants.CLIVersion.How I Tested This
curl -i http://localhost:8080/api/v1/versioncurl -I http://localhost:8080/api/v1/health