-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connectrpc: generate code with buf (#4540)
Generate the additional code required for connectrpc with the buf tool. Currently, there is no bazel ruleset available for buf generation. However, we can leverage buf as a protoc plugin as shown in https://github.com/abitofhelp/connect-go-example. With the help of some convenience macro, source code is copied with our regular `write_all_source_files` Make target. This PR is broken out of the https://github.com/scionproto/scion/tree/connectrpc branch to make incremental review easier. Contributes to #4434
- Loading branch information
Showing
27 changed files
with
1,934 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
build: | ||
roots: | ||
- . | ||
excludes: | ||
- anapaya/protobuf | ||
version: v1 | ||
breaking: | ||
use: | ||
- FILE | ||
lint: | ||
use: | ||
- DEFAULT | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports_files(glob(["**/*.patch"])) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Patch is copied from https://github.com/abitofhelp/connect-go-example/blob/main/import.patch | ||
|
||
It is required because of the issue described in https://github.com/bazelbuild/rules_go/issues/3951. | ||
The connect protoc plugin generates files in a sub-directory, which is not supported by the rules_go. | ||
This patch allows to override the import path of the generated files. | ||
|
||
There is also an upstream discussion whether there should be support for generating files in | ||
the directory itself rather than in a sub-directory. See: | ||
https://github.com/connectrpc/connect-go/discussions/310 | ||
|
||
--- proto/def.bzl | ||
+++ proto/def.bzl | ||
@@ -123,8 +123,12 @@ def _go_proto_library_impl(ctx): | ||
imports = get_imports(ctx.attr, go.importpath), | ||
importpath = go.importpath, | ||
)) | ||
+ importpath = None | ||
+ if ctx.attr.overrideimportpath: | ||
+ importpath = ctx.attr.overrideimportpath | ||
library = go.new_library( | ||
go, | ||
+ importpath = importpath, | ||
resolver = _proto_library_to_source, | ||
srcs = go_srcs, | ||
) | ||
@@ -164,6 +168,7 @@ go_proto_library = rule( | ||
"importpath": attr.string(), | ||
"importmap": attr.string(), | ||
"importpath_aliases": attr.string_list(), # experimental, undocumented | ||
+ "overrideimportpath": attr.string(), | ||
"embed": attr.label_list(providers = [GoLibrary]), | ||
"gc_goopts": attr.string_list(), | ||
"compiler": attr.label(providers = [GoProtoCompiler]), | ||
-- |
Empty file modified
0
pkg/proto/control_plane/experimental/seg_detached_extensions.pb.go
100755 → 100644
Empty file.
12 changes: 12 additions & 0 deletions
12
pkg/proto/control_plane/v1/control_planeconnect/BUILD.bazel
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("//tools/proto:connect.bzl", "go_connect_library") | ||
|
||
go_connect_library( | ||
name = "go_default_library", | ||
files = [ | ||
"cppki.connect.go", | ||
"drkey.connect.go", | ||
"renewal.connect.go", | ||
"seg.connect.go", | ||
], | ||
proto = "control_plane", | ||
) |
146 changes: 146 additions & 0 deletions
146
pkg/proto/control_plane/v1/control_planeconnect/cppki.connect.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.