forked from open-telemetry/opentelemetry-demo
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate protobuf code for Go and Python services (open-telemetry#1794)
Part of open-telemetry#1787 to generate profobuf files for all services. This should help unblock open-telemetry#1754 to allow dependabot to manage dependecy upgrades for the Go services. There are new Makefile recipes for managing the protobuf files. 1. docker-generate-protobuf - to generate the protobuf files with docker so that the only dependency on the machine needed is docker. 2. clean - to remove the protobuf files generated 3. check-clean-work-tree - to check that the working tree is clean and to help with verifying that the protobuf files are updated for all of the services when there are changes to the protobuf definition. There's a new check in the GitHub Actions workflow to verify that the protobuf code is generated. It is only verifying that the protobuf code is generated for Go and Python, but other services can apply the same workflow by updating the docker-gen-proto.sh script to uncomment the function call for the service. The dockerfiles for the Go and Python services have been updated to not generate the protobuf files during the build process. Instead, this function has been refactored into the genproto directory of each service. Signed-off-by: Charlie Le <[email protected]>
- Loading branch information
1 parent
bb71866
commit 93b8f1a
Showing
22 changed files
with
10,588 additions
and
47 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
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,35 @@ | ||
#!/bin/sh | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e # Exit immediately if a command exits with a non-zero status. | ||
set -x # Print commands and their arguments as they are executed | ||
|
||
# This script is used to generate protobuf files for all services with Docker. | ||
|
||
gen_proto_go() { | ||
echo "Generating Go protobuf files for $1" | ||
docker build -f "src/$1/genproto/Dockerfile" -t "$1-genproto" . | ||
docker run --rm -v $(pwd):/build "$1-genproto" \ | ||
protoc -I /build/pb /build/pb/demo.proto --go_out="./src/$1/" --go-grpc_out="./src/$1/" | ||
} | ||
|
||
gen_proto_python() { | ||
echo "Generating Python protobuf files for $1" | ||
docker build -f "src/$1/genproto/Dockerfile" -t "$1-genproto" . | ||
docker run --rm -v $(pwd):/build "$1-genproto" \ | ||
python -m grpc_tools.protoc -I /build/pb/ --python_out="./src/$1/" --grpc_python_out="./src/$1/" /build/pb/demo.proto | ||
} | ||
|
||
#gen_proto_dotnet accountingservice | ||
#gen_proto_java adservice | ||
#gen_proto_dotnet cartservice | ||
gen_proto_go checkoutservice | ||
#gen_proto_cpp currencyservice | ||
#gen_proto_ruby emailservice | ||
#gen_proto_ts frontend | ||
#gen_proto_js paymentservice | ||
gen_proto_go productcatalogservice | ||
#gen_proto_php quoteservice | ||
gen_proto_python recommendationservice | ||
#gen_proto_rust shippingservice |
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,16 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM golang:1.22-alpine | ||
|
||
WORKDIR /build | ||
|
||
RUN apk add --no-cache protobuf-dev | ||
|
||
COPY ./src/checkoutservice/go.mod ./ | ||
COPY ./src/checkoutservice/go.sum ./ | ||
COPY ./src/checkoutservice/tools.go ./ | ||
|
||
RUN go env -w GOMODCACHE=/root/.cache/go-build | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly |
Oops, something went wrong.