scripts: move gateway stubs into gw/ packages

release-3.2
Anthony Romano 2017-04-18 22:25:57 -07:00
parent 04fc57ac1d
commit fd11523af9
1 changed files with 18 additions and 2 deletions

View File

@ -69,14 +69,30 @@ for dir in ${DIRS}; do
done
for pb in etcdserverpb/rpc api/v3lock/v3lockpb/v3lock api/v3election/v3electionpb/v3election; do
protobase="etcdserver/${pb}"
protoc -I. \
-I${GRPC_GATEWAY_ROOT}/third_party/googleapis \
-I${GOGOPROTO_PATH} \
-I${COREOS_ROOT} \
--grpc-gateway_out=logtostderr=true:. \
--swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \
./etcdserver/${pb}.proto
name=`basename ${pb}`
${protobase}.proto
# hack to move gw files around so client won't include them
pkgpath=`dirname ${protobase}`
pkg=`basename ${pkgpath}`
gwfile="${protobase}.pb.gw.go"
sed -i.bak -E "s/package $pkg/package gw/g" ${gwfile}
sed -i.bak -E "s/protoReq /&$pkg\./g" ${gwfile}
sed -i.bak -E "s/, client /, client $pkg./g" ${gwfile}
sed -i.bak -E "s/Client /, client $pkg./g" ${gwfile}
sed -i.bak -E "s/[^(]*Client, runtime/${pkg}.&/" ${gwfile}
sed -i.bak -E "s/New[A-Za-z]*Client/${pkg}.&/" ${gwfile}
# darwin doesn't like newlines in sed...
sed -i.bak -E "s|import \(|& \"github.com/coreos/etcd/${pkgpath}\"|" ${gwfile}
mkdir -p ${pkgpath}/gw/
go fmt ${gwfile}
mv ${gwfile} ${pkgpath}/gw/
rm -f ./etcdserver/${pb}*.bak
mv Documentation/dev-guide/apispec/swagger/etcdserver/${pb}.swagger.json \
Documentation/dev-guide/apispec/swagger/${name}.swagger.json
done