Skip to content

Commit

Permalink
Make grpc gateway generate code at the correct location and alias at …
Browse files Browse the repository at this point in the history
…the wrong location (#1333)

Our patch to gRPC gateway had a
[bug](#1223). It generated code
at the wrong location: what should be generated at
`foo/v1/v1gateway/filename.pb.gw.go` is generated at
`foo/v1/filename/v1gateway/filename.pb.gw.go`.

This fixes it by generating the code now at the correct location, but
continuing to generate aliases (`Func = aliaspackage.Func`) at the
incorrect location to stay backward compatible.

***Catch:*** However, if the user has both `foo/bar.proto` and
`foo/bar/bar.proto`, `buf generate` will fail with `duplicate generated
file name "foo/bar/foogateway/bar.pb.gw.go". Generation will continue
without error here and drop the second occurrence of this file, but
please raise an issue with the maintainer of the plugin.` But this
should be very rare, and it shouldn't happen in general if the user uses
managed mode and end their directory path with a version number.

It's probably easier to review the actual [code
diff](oliversun9/grpc-gateway@osn/initial-state...osn/alias).

***Question:*** I also assume that a revision will be generated on
merge?
  • Loading branch information
oliversun9 authored Jul 8, 2024
1 parent 4476fe6 commit 7b2f768
Show file tree
Hide file tree
Showing 3 changed files with 396 additions and 37 deletions.
1 change: 1 addition & 0 deletions plugins/grpc-ecosystem/gateway/v2.20.0/buf.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ output_languages:
- go
registry:
go:
min_version: "1.20"
deps:
- module: github.com/grpc-ecosystem/grpc-gateway/v2
version: v2.20.0
Expand Down
Loading

0 comments on commit 7b2f768

Please sign in to comment.