feat: add /version endpoint and global Minder-Version header#6358
feat: add /version endpoint and global Minder-Version header#6358DharunMR wants to merge 1 commit into
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)) |
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.
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
4ade151 to
5967607
Compare
Signed-off-by: DharunMR <maddharun56@gmail.com>
5967607 to
15b9407
Compare
|
This PR needs additional information before we can continue. It is now marked as stale because it has been open for 30 days with no activity. Please provide the necessary details to continue or it will be closed in 30 days. |

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