teleport/build.assets/genproto.sh
Rafał Cieślak 3ac5a0aedb
Refactor prehog & teleterm protos to match project conventions (#20810)
* Adjust go_package of lib/prehog Go protobufs

This makes them follow the pattern set out by api/proto and proto.

* Adjust go_package of lib/teleterm Go protobufs

* Use single buf.gen.yaml to generate JS protos

This also entailed changing the location of lib/teleterm protos and changing
the value of their package specifier to match the conventions in other parts
of the codebase. This is a breaking change but that is fine for Connect
as the protos are used locally only and each build ships with matching
protobufs.

* Make web/packages/teleterm use protobufs from gen-proto-js

We used to copy protobufs over to web/packages/teleterm/src/services/tshd
since webapps used to be in a separate repo.

This is no longer the case, so we can just make teleterm use protobufs
from gen-proto-js.

* Move prehog & teleterm protos into proto/teleport/lib

* Generate JS protos to gen/proto/js

* Move lib/teleterm Go protobufs to gen/proto/go

* Move lib/prehog Go protobufs to gen/proto/go

* Rename lib/teleterm proto package

* Re-enable linter rules for teleterm & prehog

* Update prehogv1 path in usagereporter_test.go

* Use except instead of ignore_only to allow Google API-style responses

* Add UNARY_RPC to api/proto & proto

* Ignore gen/ when running addlicense

* buf-js.gen.yaml: Remove comment about lack of go_package for JS

* Move prehog protos to proto/prehog/v1alpha

* Adjust prehog's go_package to match proto package
2023-02-03 14:47:06 +00:00

42 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Generates protos for Teleport and Teleport API.
set -eu
main() {
cd "$(dirname "$0")" # ./build-assets/
cd ../ # teleport root
# Generated protos are written to
# <teleport-root>/github.com/gravitational/teleport/..., so we copy them to
# the correct relative path.
trap 'rm -fr github.com' EXIT # don't leave github.com/ behind
rm -fr api/gen/proto gen/proto # cleanup gen/proto folders
# Generate Gogo protos.
buf generate --template=buf-gogo.gen.yaml api/proto
buf generate --template=buf-gogo.gen.yaml proto
# 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/loginrule/ \
--path=api/proto/teleport/proxy/ \
--path=proto/teleport/lib/multiplexer/ \
--path=proto/teleport/lib/teleterm/
# Generate connect-go protos.
buf generate --template=buf-connect-go.gen.yaml \
--path=proto/prehog/
# Generate JS protos.
buf generate --template=buf-js.gen.yaml \
--path=proto/prehog/ \
--path=proto/teleport/lib/teleterm/
cp -r github.com/gravitational/teleport/* .
}
main "$@"