mirror of
https://github.com/gravitational/teleport
synced 2024-10-19 16:53:57 +00:00
983e0cc611
* Support non-gogo objects for auth service events. Auth service events will now support non-gogo objects. This was done by generating the events and associated objects with regular go protobuf instead of gogo and then correcting the code for the differences in code generation. * Correct lock copying in event protobuf. * Temporarily ignore event.proto in buf breaking. * Attempt to keep buf breaking from breaking. * Remove comment. * Rename gproto to googleproto. * Rename api/client/proto import to authpb and googleproto to proto. * Correct comment, add in test exercising proto.Equal. * GCI. * Events test actually does work.
80 lines
2.6 KiB
Bash
Executable file
80 lines
2.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Generates protos for Teleport and Teleport API.
|
|
set -eu
|
|
|
|
echoed() {
|
|
echo "$*" >&2
|
|
"$@"
|
|
}
|
|
|
|
main() {
|
|
cd "$(dirname "$0")" # ./build-assets/
|
|
cd ../ # teleport root
|
|
|
|
# Parse optional args.
|
|
local skip_js=0 # skips Javascript and Typescript protogen
|
|
local skip_rm=0 # skips removal of old protos
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--skip-js)
|
|
skip_js=1
|
|
;;
|
|
--skip-rm)
|
|
skip_rm=1
|
|
;;
|
|
*)
|
|
echo "Unknown argument $1" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# Clean gen/proto directories before regenerating them. Legacy protos are
|
|
# generated all over the directory tree, so they won't get cleaned up
|
|
# automatically if the proto is deleted.
|
|
[[ $skip_rm -eq 0 ]] && echoed rm -fr api/gen/proto gen/proto
|
|
|
|
# Generate Gogo protos. Generated protos are written to
|
|
# gogogen/github.com/gravitational/teleport/..., so we copy them to the
|
|
# correct relative path. This is in lieu of the module= option, which would do
|
|
# 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
|
|
echoed 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 \
|
|
--exclude-path=api/proto/teleport/legacy/client/proto/event.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).
|
|
echoed buf generate --template=buf-go.gen.yaml \
|
|
--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 event.proto separately because we only want to run it on this
|
|
# one particular file in legacy.
|
|
echoed buf generate --template=buf-go.gen.yaml \
|
|
--path=api/proto/teleport/legacy/client/proto/event.proto
|
|
|
|
# Generate connect-go protos.
|
|
echoed buf generate --template=buf-connect-go.gen.yaml \
|
|
--path=proto/prehog/
|
|
|
|
# Generate JS protos.
|
|
[[ $skip_js -eq 0 ]] && echoed buf generate --template=buf-js.gen.yaml \
|
|
--path=proto/prehog/ \
|
|
--path=proto/teleport/lib/teleterm/
|
|
}
|
|
|
|
main "$@"
|