Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make grpc gateway v2.21.0 #1385

Merged
merged 8 commits into from
Jul 31, 2024
Merged

Make grpc gateway v2.21.0 #1385

merged 8 commits into from
Jul 31, 2024

Conversation

oliversun9
Copy link
Contributor

@oliversun9 oliversun9 commented Jul 29, 2024

Ran go run ./internal/cmd/fetcher plugins/grpc-ecosystem and updated the patch for the version.

upstream release changelog

Patch diff:

diff plugins/grpc-ecosystem/gateway/v2.21.0/separate_pkg_additional_imports.patch plugins/grpc-ecosystem/gateway/v2.20.0/separate_pkg_additional_imports.patch
71c71
< index 684fc5b6..c1b69363 100644
---
> index 421c0089..26bed31a 100644
88c88
< @@ -255,6 +262,9 @@ func (r *Registry) loadFile(filePath string, file *protogen.File) {
---
> @@ -252,6 +259,9 @@ func (r *Registry) loadFile(filePath string, file *protogen.File) {
577c577
< index 9975e424..13332ef7 100644
---
> index ffe4d413..fdd9bc5b 100644
649c649
< @@ -606,6 +624,9 @@ func local_request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ct
---
> @@ -606,12 +624,18 @@ func local_request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ct
659c659
< @@ -613,6 +634,9 @@ func local_request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ct
---
>  // UnaryRPC     :call {{$svc.GetName}}Server directly.
662d661
<  // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
669c668
< @@ -664,6 +688,7 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server(ctx context.Context,
---
> @@ -663,6 +687,7 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server(ctx context.Context,
677c676
< @@ -671,6 +696,9 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server(ctx context.Context,
---
> @@ -670,6 +695,9 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server(ctx context.Context,
687c686
< @@ -693,18 +721,26 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}FromEndpoint(ctx context.Co
---
> @@ -692,18 +720,26 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}FromEndpoint(ctx context.Co
707c706
<  // "{{$svc.InstanceName}}Client" to call the correct interceptors. This client ignores the HTTP middlewares.
---
>  // "{{$svc.InstanceName}}Client" to call the correct interceptors.
714c713
< @@ -785,5 +821,9 @@ var (
---
> @@ -784,5 +820,9 @@ var (
726c725
< index 086a4624..5f65b894 100644
---
> index 5a1e6977..7e89ad1c 100644
737c736
< @@ -36,6 +37,7 @@ var (
---
> @@ -35,6 +36,7 @@ var (
745c744
< @@ -73,15 +75,22 @@ func main() {
---
> @@ -58,15 +60,22 @@ func main() {
772c771
< @@ -135,6 +144,7 @@ func applyFlags(reg *descriptor.Registry) error {
---
> @@ -120,6 +129,7 @@ func applyFlags(reg *descriptor.Registry) error {

Upstream diff in plugin

git --no-pager diff v2.20.0..v2.21.0 protoc-gen-grpc-gateway
diff --git a/protoc-gen-grpc-gateway/internal/gengateway/template.go b/protoc-gen-grpc-gateway/internal/gengateway/template.go
index ffe4d413..9975e424 100644
--- a/protoc-gen-grpc-gateway/internal/gengateway/template.go
+++ b/protoc-gen-grpc-gateway/internal/gengateway/template.go
@@ -612,6 +612,7 @@ func local_request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ct
 // UnaryRPC     :call {{$svc.GetName}}Server directly.
 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
 // Note that using this registration option will cause many gRPC library features to stop working. Consider using Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}FromEndpoint instead.
+// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
 func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server(ctx context.Context, mux *runtime.ServeMux, server {{$svc.InstanceName}}Server) error {
 	{{range $m := $svc.Methods}}
 	{{range $b := $m.Bindings}}
@@ -703,7 +704,7 @@ func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}(ctx context.Context, mux *
 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "{{$svc.InstanceName}}Client".
 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "{{$svc.InstanceName}}Client"
 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "{{$svc.InstanceName}}Client" to call the correct interceptors.
+// "{{$svc.InstanceName}}Client" to call the correct interceptors. This client ignores the HTTP middlewares.
 func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Client(ctx context.Context, mux *runtime.ServeMux, client {{$svc.InstanceName}}Client) error {
 	{{range $m := $svc.Methods}}
 	{{range $b := $m.Bindings}}
diff --git a/protoc-gen-grpc-gateway/main.go b/protoc-gen-grpc-gateway/main.go
index 5a1e6977..086a4624 100644
--- a/protoc-gen-grpc-gateway/main.go
+++ b/protoc-gen-grpc-gateway/main.go
@@ -13,6 +13,7 @@ import (
 	"flag"
 	"fmt"
 	"os"
+	"runtime/debug"
 	"strings"

 	"github.com/grpc-ecosystem/grpc-gateway/v2/internal/codegenerator"
@@ -50,6 +51,20 @@ func main() {
 	flag.Parse()

 	if *versionFlag {
+		if commit == "unknown" {
+			buildInfo, ok := debug.ReadBuildInfo()
+			if ok {
+				version = buildInfo.Main.Version
+				for _, setting := range buildInfo.Settings {
+					if setting.Key == "vcs.revision" {
+						commit = setting.Value
+					}
+					if setting.Key == "vcs.time" {
+						date = setting.Value
+					}
+				}
+			}
+		}
 		fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date)
 		os.Exit(0)
 	}

@mfridman
Copy link
Member

mfridman commented Jul 29, 2024

You'll also need to run the following command to generate the checksum file:

make test PLUGINS="grpc-ecosystem/gateway:v2.21.0" 

@mfridman
Copy link
Member

Okay @oliversun9, you fixed the tests and the fetcher is back to working. #1387

Can you look at go-grpc first, get that fixed up and then we'll pick this patch up last.

Please also enable these, effectively undoing #1384

@oliversun9 oliversun9 requested a review from mfridman July 29, 2024 21:56
@mfridman
Copy link
Member

mfridman commented Jul 31, 2024

Can you remind me, was it primarily a few Go comments that changed between the previous diff and the current diff that lead to a merge conflict?

@oliversun9
Copy link
Contributor Author

oliversun9 commented Jul 31, 2024

Can you remind me, was it primarily a few Go comments that changed between the previous diff and the current diff that lead to a merge conflict?

Yes, the plugin generates two extra lines of comments. Also just updated PR description to show that.

- separate_package=true
deps:
- plugin: buf.build/protocolbuffers/go:v1.34.2
- plugin: buf.build/grpc/go:v1.5.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on newer versions now

@oliversun9 oliversun9 merged commit e3e37a0 into main Jul 31, 2024
6 checks passed
@oliversun9 oliversun9 deleted the osun/grpc-gateway-v2.21.0 branch July 31, 2024 15:48
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.

3 participants