-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrade from github.com/golang/protobuf to google.golang.org/protobuf #2644
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,35 +16,48 @@ | |
|
||
set -ex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aligned to |
||
|
||
header() { | ||
cat /go/src/agones.dev/agones/build/boilerplate.go.txt "$1" | sponge "$1" | ||
} | ||
|
||
export GO111MODULE=on | ||
|
||
mkdir -p /go/src/ | ||
cp -r /go/src/agones.dev/agones/vendor/* /go/src/ | ||
|
||
cd /go/src/agones.dev/agones | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 | ||
|
||
outputpath=pkg/allocation/go | ||
protopath=proto/allocation | ||
googleapis=/go/src/agones.dev/agones/proto/googleapis | ||
gatewaygrpc=/go/src/agones.dev/agones/proto/grpc-gateway | ||
protofile=${protopath}/allocation.proto | ||
|
||
rm ./${outputpath}/allocation.pb.go || true | ||
rm ./${outputpath}/allocation.gw.pb.go || true | ||
rm ./${outputpath}/allocation_grpc.pb.go || true | ||
|
||
# generate the go code | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I . -I ./vendor ${protofile} --go_out=proto --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=proto | ||
|
||
# generate grpc gateway | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I . -I ./vendor ${protofile} --go_out=proto --grpc-gateway_out=logtostderr=true:proto | ||
|
||
# generate openapi v2 | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I . -I ./vendor ${protofile} --openapiv2_opt=logtostderr=true,simple_operation_ids=true,disable_default_errors=true --openapiv2_out=logtostderr=true:. | ||
|
||
protoc -I ${googleapis} -I . -I ./vendor ${protofile} --go_out=plugins=grpc:. | ||
protoc -I ${googleapis} -I . -I ./vendor ${protofile} --grpc-gateway_out=logtostderr=true:. | ||
protoc -I ${googleapis} -I . -I ./vendor ${protofile} --swagger_out=logtostderr=true:. | ||
jq 'del(.schemes[] | select(. == "http"))' ./${protopath}/allocation.swagger.json > ./${outputpath}/allocation.swagger.json | ||
|
||
cat ./build/boilerplate.go.txt ./${protopath}/allocation.pb.go >> ./allocation.pb.go | ||
cat ./build/boilerplate.go.txt ./${protopath}/allocation.pb.gw.go >> ./allocation.pb.gw.go | ||
rm ${protopath}/allocation.swagger.json | ||
|
||
goimports -w ./allocation.pb.go | ||
goimports -w ./allocation.pb.gw.go | ||
header ${protopath}/allocation.pb.go | ||
header ${protopath}/allocation.pb.gw.go | ||
header ${protopath}/allocation_grpc.pb.go | ||
|
||
mv ./allocation.pb.go ./${outputpath}/allocation.pb.go | ||
mv ./allocation.pb.gw.go ./${outputpath}/allocation.gw.pb.go | ||
mv ${protopath}/allocation.pb.go ${outputpath}/allocation.pb.go | ||
mv ${protopath}/allocation.pb.gw.go ${outputpath}/allocation.pb.gw.go | ||
mv ${protopath}/allocation_grpc.pb.go ${outputpath}/allocation_grpc.pb.go | ||
|
||
rm ./${protopath}/allocation.pb.go | ||
rm ./${protopath}/allocation.pb.gw.go | ||
rm ./${protopath}/allocation.swagger.json | ||
goimports -w ./${outputpath} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,20 +22,23 @@ header() { | |
|
||
sdk=/go/src/agones.dev/agones/proto/sdk | ||
googleapis=/go/src/agones.dev/agones/proto/googleapis | ||
gatewaygrpc=/go/src/agones.dev/agones/proto/grpc-gateway | ||
protoc_intermediate=/go/src/agones.dev/agones/sdks/cpp/.generated | ||
protoc_destination=/go/src/agones.dev/agones/sdks/cpp | ||
|
||
mkdir -p ${protoc_intermediate} | ||
mkdir -p ${protoc_destination}/src/agones | ||
mkdir -p ${protoc_destination}/src/google | ||
mkdir -p ${protoc_destination}/src/protoc-gen-openapiv2 | ||
mkdir -p ${protoc_destination}/include/agones | ||
mkdir -p ${protoc_destination}/include/google/api | ||
mkdir -p ${protoc_destination}/include/protoc-gen-openapiv2/options | ||
|
||
cd /go/src/agones.dev/agones/sdks/cpp | ||
find -name '*.pb.*' -delete | ||
cd /go/src/agones.dev/agones | ||
protoc -I ${googleapis} -I ${sdk} --grpc_out=${protoc_intermediate} --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` sdk.proto | ||
protoc -I ${googleapis} -I ${sdk} --cpp_out=dllexport_decl=AGONES_EXPORT:${protoc_intermediate} sdk.proto ${googleapis}/google/api/annotations.proto ${googleapis}/google/api/http.proto | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk} --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` --grpc_out=${protoc_intermediate} sdk.proto | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk} --cpp_out=dllexport_decl=AGONES_EXPORT:${protoc_intermediate} sdk.proto ${googleapis}/google/api/annotations.proto ${googleapis}/google/api/http.proto ${gatewaygrpc}/protoc-gen-openapiv2/options/annotations.proto ${gatewaygrpc}/protoc-gen-openapiv2/options/openapiv2.proto | ||
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unified order of -I |
||
|
||
cd ${protoc_intermediate} | ||
header sdk.grpc.pb.cc ${protoc_destination}/src/agones | ||
|
@@ -49,4 +52,10 @@ header http.pb.cc ${protoc_destination}/src/google | |
header annotations.pb.h ${protoc_destination}/include/google/api | ||
header http.pb.h ${protoc_destination}/include/google/api | ||
|
||
cd ${protoc_intermediate}/protoc-gen-openapiv2/options | ||
header annotations.pb.cc ${protoc_destination}/src/protoc-gen-openapiv2 | ||
header openapiv2.pb.cc ${protoc_destination}/src/protoc-gen-openapiv2 | ||
header annotations.pb.h ${protoc_destination}/include/protoc-gen-openapiv2/options | ||
header openapiv2.pb.h ${protoc_destination}/include/protoc-gen-openapiv2/options | ||
|
||
rm -r ${protoc_intermediate} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,52 @@ | |
|
||
set -ex | ||
|
||
header() { | ||
cat /go/src/agones.dev/agones/build/boilerplate.go.txt "$1" | sponge "$1" | ||
} | ||
|
||
sdk=/go/src/agones.dev/agones/proto/sdk | ||
googleapis=/go/src/agones.dev/agones/proto/googleapis | ||
protoc_intermediate=/go/src/agones.dev/agones/sdks/csharp/proto | ||
protoc_destination=/go/src/agones.dev/agones/sdks/csharp/sdk/generated | ||
|
||
# Generate C# proto file `Sdk.cs` | ||
protoc --csharp_out=${protoc_destination} -I ${sdk} -I ${googleapis} --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` sdk.proto | ||
protoc --csharp_out=${protoc_destination} -I ${sdk}/alpha -I ${googleapis} --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` alpha.proto | ||
# Generate proto stub? | ||
protoc --grpc_out=${protoc_destination} -I ${sdk} -I ${googleapis} --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` sdk.proto | ||
protoc --grpc_out=${protoc_destination} -I ${sdk}/alpha -I ${googleapis} --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` alpha.proto | ||
# Create temporary proto files | ||
mkdir -p ${protoc_intermediate} | ||
cp -r ${sdk} ${protoc_intermediate} | ||
|
||
# Remove protoc-gen-openapiv2 definitions because C# package doesn't support grpc-gateway | ||
sed -i -e 's/import "protoc-gen-openapiv2\/options\/annotations.proto";//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -e 's/option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -e 's/info: {//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -e 's/title: "sdk.proto";//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -z 's/version: "version not set";\n };//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -e 's/schemes: HTTP;//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -e 's/consumes: "application\/json";//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -z 's/produces: "application\/json";\n};//' ${protoc_intermediate}/sdk/sdk.proto | ||
sed -i -e 's/bool disabled = 1.*/bool disabled = 1;/' ${protoc_intermediate}/sdk/sdk.proto | ||
|
||
sed -i -e 's/import "protoc-gen-openapiv2\/options\/annotations.proto";//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -e 's/option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -e 's/info: {//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -e 's/title: "alpha.proto";//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -z 's/version: "version not set";\n };//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -e 's/schemes: HTTP;//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -e 's/consumes: "application\/json";//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -z 's/produces: "application\/json";\n};//' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
sed -i -e 's/bool bool = 1.*/bool bool = 1;/' ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
Comment on lines
+32
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is workaround. Remove protoc-gen-openapiv2 definitions from C# sdk image because C# package doesn't support grpc-gateway |
||
|
||
# Generate C# proto file like `Sdk.cs` | ||
protoc -I ${googleapis} -I ${protoc_intermediate}/sdk --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` --csharp_out=${protoc_destination} ${protoc_intermediate}/sdk/sdk.proto | ||
protoc -I ${googleapis} -I ${protoc_intermediate}/sdk/alpha --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` --csharp_out=${protoc_destination} ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
|
||
# Generate grpc file like `SdkGrpc.cs` | ||
protoc -I ${googleapis} -I ${protoc_intermediate}/sdk --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` --grpc_out=${protoc_destination} ${protoc_intermediate}/sdk/sdk.proto | ||
protoc -I ${googleapis} -I ${protoc_intermediate}/sdk/alpha --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` --grpc_out=${protoc_destination} ${protoc_intermediate}/sdk/alpha/alpha.proto | ||
|
||
cd ${protoc_destination} | ||
header Alpha.cs | ||
header AlphaGrpc.cs | ||
header Sdk.cs | ||
header SdkGrpc.cs | ||
|
||
rm -rf ${protoc_intermediate} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,43 +22,52 @@ header() { | |
|
||
sdk=/go/src/agones.dev/agones/proto/sdk | ||
googleapis=/go/src/agones.dev/agones/proto/googleapis | ||
gatewaygrpc=/go/src/agones.dev/agones/proto/grpc-gateway | ||
|
||
export GO111MODULE=on | ||
|
||
mkdir -p /go/src/ | ||
cp -r /go/src/agones.dev/agones/vendor/* /go/src/ | ||
|
||
cd /go/src/agones.dev/agones | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway | ||
go install -mod=vendor github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 | ||
|
||
mkdir -p ./pkg/sdk/{alpha,beta} || true | ||
|
||
rm ./pkg/sdk/beta/beta.pb.go || true | ||
rm ./pkg/sdk/alpha/alpha.pb.go || true | ||
rm ./pkg/sdk/beta/beta_grpc.pb.go || true | ||
rm ./pkg/sdk/alpha/alpha_grpc.pb.go || true | ||
rm ./pkg/sdk/beta/beta.pb.gw.go || true | ||
rm ./pkg/sdk/alpha/alpha.pb.gw.go || true | ||
|
||
# generate the go code for each feature stage | ||
protoc -I ${googleapis} -I ${sdk} sdk.proto --go_out=plugins=grpc:pkg/sdk | ||
protoc -I ${googleapis} -I ${sdk}/alpha alpha.proto --go_out=plugins=grpc:pkg/sdk/alpha | ||
protoc -I ${googleapis} -I ${sdk}/beta beta.proto --go_out=plugins=grpc:pkg/sdk/beta | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk} sdk.proto --go_out=pkg --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=pkg | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk}/alpha alpha.proto --go_out=pkg/sdk --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=pkg/sdk | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk}/beta beta.proto --go_out=pkg/sdk --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=pkg/sdk | ||
|
||
# generate grpc gateway | ||
protoc -I ${googleapis} -I ${sdk} sdk.proto --grpc-gateway_out=logtostderr=true:pkg/sdk | ||
protoc -I ${googleapis} -I ${sdk}/alpha alpha.proto --grpc-gateway_out=logtostderr=true:pkg/sdk/alpha | ||
protoc -I ${googleapis} -I ${sdk}/beta beta.proto --grpc-gateway_out=logtostderr=true:pkg/sdk/beta | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk} sdk.proto --grpc-gateway_out=logtostderr=true:pkg | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk}/alpha alpha.proto --grpc-gateway_out=logtostderr=true:pkg/sdk | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk}/beta beta.proto --grpc-gateway_out=logtostderr=true:pkg/sdk | ||
|
||
protoc -I ${googleapis} -I ${sdk} sdk.proto --swagger_out=logtostderr=true:sdks/swagger | ||
protoc -I ${googleapis} -I ${sdk}/alpha alpha.proto --swagger_out=logtostderr=true:sdks/swagger | ||
protoc -I ${googleapis} -I ${sdk}/beta beta.proto --swagger_out=logtostderr=true:sdks/swagger | ||
# generate openapi v2 | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk} sdk.proto --openapiv2_opt=logtostderr=true,simple_operation_ids=true,disable_default_errors=true --openapiv2_out=logtostderr=true:sdks/swagger | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk}/alpha alpha.proto --openapiv2_opt=logtostderr=true,simple_operation_ids=true,disable_default_errors=true --openapiv2_out=logtostderr=true:sdks/swagger | ||
protoc -I ${googleapis} -I ${gatewaygrpc} -I ${sdk}/beta beta.proto --openapiv2_opt=logtostderr=true,simple_operation_ids=true,disable_default_errors=true --openapiv2_out=logtostderr=true:sdks/swagger | ||
|
||
jq 'del(.schemes[] | select(. == "https"))' ./sdks/swagger/sdk.swagger.json | sponge ./sdks/swagger/sdk.swagger.json | ||
jq 'del(.schemes[] | select(. == "https"))' ./sdks/swagger/alpha.swagger.json | sponge ./sdks/swagger/alpha.swagger.json | ||
jq 'del(.schemes[] | select(. == "https"))' ./sdks/swagger/beta.swagger.json | sponge ./sdks/swagger/beta.swagger.json | ||
# hard coding because protoc-gen-openapiv2 doesn't work well in Stream and doesn't generate 'googlerpcStatus' and 'protobufAny' definitions | ||
cat sdks/swagger/sdk.swagger.json | jq '.definitions |= .+{"googlerpcStatus": {"type": "object", "properties": { "code": { "type": "integer", "format": "int32"}, "message": { "type":"string"}, "details": { "type": "array", "items": { "$ref": "#/definitions/protobufAny"}}}}}' | sponge sdks/swagger/sdk.swagger.json | ||
cat sdks/swagger/sdk.swagger.json | jq '.definitions |= .+{"protobufAny": { "type": "object", "properties": { "@type": { "type": "string" }}, "additionalProperties": {}},}' | sponge sdks/swagger/sdk.swagger.json | ||
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is workaround. Add jq logic to sdks/swagger/sdk.swagger.json because protoc-gen-openapiv2 doesn't work well in Stream and doesn't generate nessesary definitions. If |
||
|
||
header ./pkg/sdk/sdk.pb.go | ||
header ./pkg/sdk/sdk.pb.gw.go | ||
header ./pkg/sdk/alpha/alpha.pb.go | ||
header ./pkg/sdk/beta/beta.pb.go | ||
header ./pkg/sdk/sdk.pb.gw.go | ||
header ./pkg/sdk/sdk_grpc.pb.go | ||
header ./pkg/sdk/alpha/alpha_grpc.pb.go | ||
header ./pkg/sdk/beta/beta_grpc.pb.go | ||
|
||
# these files may not exist if there are no grpc services | ||
if [ -f "./pkg/sdk/alpha/alpha.pb.gw.go" ]; then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,6 @@ | |
set -ex | ||
GO111MODULE=on | ||
cd /go/src/agones.dev/agones/test/sdk/restapi | ||
# swagger gen has a bug wherein it doesn't generate the file, so we're providing it by hand | ||
cp ./model_xstreamdefinitionssdkgameserver.go.nolint ./swagger/model_xstreamdefinitionssdkgameserver.go | ||
Comment on lines
-20
to
-21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
cp ./http-api-test.go.nolint ./http-api-test.go | ||
go run http-api-test.go | ||
cd /go/src/agones.dev/agones/test/sdk/websocket-watch | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make gen-allocation-grpc
is defined in Makefile, but this was not described inbuild/README.md