Skip to content

Commit

Permalink
Tweak protogen to not change protos from cloud (gravitational#24688)
Browse files Browse the repository at this point in the history
* Tweak protogen to not change protos from cloud

* Use strategy: all whenever possible
  • Loading branch information
espadolini authored Apr 18, 2023
1 parent 8a76c17 commit 2966be6
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 47 deletions.
6 changes: 6 additions & 0 deletions buf-connect-go.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/gravitational/teleport/gen/proto/go
plugins:
- name: go
strategy: all
path:
- go
- run
- google.golang.org/protobuf/cmd/protoc-gen-go
out: .
opt: module=github.com/gravitational/teleport
- name: connect-go
strategy: all
path:
- go
- run
Expand Down
12 changes: 10 additions & 2 deletions buf-go.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
version: v1
plugins:
- name: go
strategy: all
path:
- go
- run
- google.golang.org/protobuf/cmd/protoc-gen-go
out: .
opt: module=github.com/gravitational/teleport
opt:
- module=github.com/gravitational/teleport
# needed by teleport/lib/teleterm/v1/usage_events.proto
- Mprehog/v1alpha/connect.proto=github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha
- name: go-grpc
strategy: all
path:
- go
- run
- google.golang.org/grpc/cmd/protoc-gen-go-grpc
out: .
opt: module=github.com/gravitational/teleport
opt:
- module=github.com/gravitational/teleport
# needed by teleport/lib/teleterm/v1/usage_events.proto
- Mprehog/v1alpha/connect.proto=github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha
3 changes: 3 additions & 0 deletions buf-js.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ version: v1
plugins:
# https://github.com/protocolbuffers/protobuf/tree/v3.20.1/js
- name: js
strategy: all
out: gen/proto/js
opt:
- import_style=commonjs,binary

# https://github.com/grpc/grpc-node/tree/grpc-tools%401.12.4/packages/grpc-tools/
- name: grpc
strategy: all
out: gen/proto/js
opt: grpc_js
path: grpc_tools_node_protoc_plugin

# https://github.com/agreatfool/grpc_tools_node_protoc_ts/tree/v5.0.1
- name: ts
strategy: all
out: gen/proto/js
opt: "service=grpc-node"
23 changes: 10 additions & 13 deletions build.assets/genproto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ main() {
# this for us (and which is what we use for the non-gogo protogen).
rm -fr gogogen
trap 'rm -fr gogogen' EXIT # don't leave files behind
buf generate --template=buf-gogo.gen.yaml
buf generate --template=buf-gogo.gen.yaml \
--path=api/proto/teleport/legacy/ \
--path=api/proto/teleport/attestation/ \
--path=api/proto/teleport/usageevents/ \
--path=proto/teleport/lib/web/envelope.proto
cp -r gogogen/github.com/gravitational/teleport/. .
# error out if there's anything outside of github.com/gravitational/teleport
rm -fr gogogen/github.com/gravitational/teleport
rmdir gogogen/github.com/gravitational gogogen/github.com gogogen

# Generate protoc-gen-go protos (preferred).
# Add your protos to the list if you can.
buf generate --template=buf-go.gen.yaml \
--path=api/proto/teleport/devicetrust/ \
--path=api/proto/teleport/integration/ \
--path=api/proto/teleport/kube/ \
--path=api/proto/teleport/loginrule/ \
--path=api/proto/teleport/okta/ \
--path=api/proto/teleport/plugins/ \
--path=api/proto/teleport/samlidp/ \
--path=api/proto/teleport/transport/ \
--path=api/proto/teleport/trust/ \
--path=proto/teleport/lib/multiplexer/ \
--path=proto/teleport/lib/teleterm/
--exclude-path=api/proto/teleport/legacy/ \
--exclude-path=api/proto/teleport/attestation/ \
--exclude-path=api/proto/teleport/usageevents/ \
--exclude-path=proto/teleport/lib/web/envelope.proto \
--exclude-path=proto/prehog/

# Generate connect-go protos.
buf generate --template=buf-connect-go.gen.yaml \
Expand Down
18 changes: 12 additions & 6 deletions gen/proto/go/prehog/v1/teleport.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions gen/proto/go/prehog/v1alpha/connect.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions gen/proto/go/prehog/v1alpha/tbot.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions gen/proto/go/prehog/v1alpha/teleport.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions proto/prehog/v1/teleport.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package prehog.v1;

import "google/protobuf/timestamp.proto";

option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1;prehogv1";

message UserActivityReport {
// randomly generated UUID for this specific report, 16 bytes (in string order)
bytes report_uuid = 1;
Expand Down
2 changes: 0 additions & 2 deletions proto/prehog/v1alpha/connect.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package prehog.v1alpha;

import "google/protobuf/timestamp.proto";

option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha";

message ConnectClusterLoginEvent {
// anonymized
string cluster_name = 1;
Expand Down
2 changes: 0 additions & 2 deletions proto/prehog/v1alpha/tbot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package prehog.v1alpha;

import "google/protobuf/timestamp.proto";

option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha";

// TbotStartEvent is triggered whenever tbot starts, regardless of whether tbot
// was able to successfully connect to or authenticate with a Teleport cluster.
message TbotStartEvent {
Expand Down
2 changes: 0 additions & 2 deletions proto/prehog/v1alpha/teleport.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package prehog.v1alpha;
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha";

message UserLoginEvent {
// anonymized
string user_name = 1;
Expand Down

0 comments on commit 2966be6

Please sign in to comment.