Skip to content

Commit

Permalink
Apply patches on the generated *.pb.gw.go files to convert v1 message…
Browse files Browse the repository at this point in the history
…s to v2 messages

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Sep 13, 2023
1 parent f2d01c6 commit b6666de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/genproto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ for pb in api/etcdserverpb/rpc server/etcdserver/api/v3lock/v3lockpb/v3lock serv
Documentation/dev-guide/apispec/swagger/"${swaggerName}".swagger.json
done

# We only upgraded grpc-gateway from v1 to v2, but keep gogo/protobuf as it's for now.
# So we have to convert v1 message to v2 message. Once we get rid of gogo/protobuf, and
# start to depend on protobuf v2, then we can remove this patch.
for pb in api/etcdserverpb/rpc server/etcdserver/api/v3lock/v3lockpb/v3lock server/etcdserver/api/v3election/v3electionpb/v3election; do
gwfile="$(dirname ${pb})/gw/$(basename ${pb}).pb.gw.go"

run set -i -E "s#return msg, metadata, err#return protov1.MessageV2(msg), metadata, err#g" "${gwfile}"
run sed -i -E "s#Decode\(\&protoReq\)#Decode\(protov1\.MessageV2\(\&protoReq\)\)#g" "${gwfile}"
run go fmt "${gwfile}"
done

if [ "${1:-}" != "--skip-protodoc" ]; then
log_callout "protodoc is auto-generating grpc API reference documentation..."

Expand Down

0 comments on commit b6666de

Please sign in to comment.