Skip to content

Commit

Permalink
wip: use go.mod installed api and apimachinery to generate proto files
Browse files Browse the repository at this point in the history
  • Loading branch information
a9p committed Jun 4, 2023
1 parent 9dcbd9f commit 8da4db2
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions pkg/apis/manager/v1beta1/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,33 @@ cd "$(dirname "$0")"

proto="api.proto"

git clone --depth 1 --branch kubernetes-1.22.17 https://github.com/kubernetes/api.git k8s.io/api
git clone --depth 1 --branch kubernetes-1.22.17 https://github.com/kubernetes/apimachinery.git k8s.io/apimachinery

docker run -i --rm -v "$PWD:$PWD" -w "$PWD" znly/protoc --python_out=plugins=grpc:./python --go_out=plugins=grpc:. -I. $proto
docker run -i --rm -v "$PWD:$PWD" -w "$PWD" znly/protoc --plugin=protoc-gen-grpc=/usr/bin/grpc_python_plugin --python_out=./python --grpc_out=./python -I. $proto

rm -rf k8s.io
# Get host paths for kubernetes api modules
GO_MOD_K8S_API=$(go list -m -f '{{.Dir}}' k8s.io/api)
GO_MOD_K8S_APIMACHINERY=$(go list -m -f '{{.Dir}}' k8s.io/apimachinery)

docker run -i --rm \
-v "$PWD:$PWD" \
-v "$GO_MOD_K8S_API:$GOPATH/pkg/mod/k8s.io/api" \
-v "$GO_MOD_K8S_APIMACHINERY:$GOPATH/pkg/mod/k8s.io/apimachinery" \
-w "$PWD" \
znly/protoc --python_out=plugins=grpc:./python --go_out=plugins=grpc:. -I="$GOPATH/pkg/mod/" -I. $proto
docker run -i --rm \
-v "$PWD:$PWD" \
-v "$GO_MOD_K8S_API:$GOPATH/pkg/mod/k8s.io/api" \
-v "$GO_MOD_K8S_APIMACHINERY:$GOPATH/pkg/mod/k8s.io/apimachinery" \
-w "$PWD" \
znly/protoc --plugin=protoc-gen-grpc=/usr/bin/grpc_python_plugin --python_out=./python --grpc_out=./python -I "$GOPATH/pkg/mod/" -I. $proto

docker build -t protoc-gen-doc gen-doc/
docker run --rm -v "$PWD/gen-doc:/out" -v "$PWD:/apiprotos" protoc-gen-doc --doc_opt=markdown,api.md -I /protobuf -I /apiprotos $proto
docker run --rm -v "$PWD/gen-doc:/out" -v "$PWD:/apiprotos" protoc-gen-doc --doc_opt=html,index.html -I /protobuf -I /apiprotos $proto
docker run --rm \
-v "$PWD/gen-doc:/out" \
-v "$PWD:/apiprotos" \
-v "$GO_MOD_K8S_API:$GOPATH/pkg/mod/k8s.io/api" \
-v "$GO_MOD_K8S_APIMACHINERY:$GOPATH/pkg/mod/k8s.io/apimachinery" \
protoc-gen-doc --doc_opt=markdown,api.md -I "$GOPATH/pkg/mod/" -I /protobuf -I /apiprotos $proto
docker run --rm \
-v "$PWD/gen-doc:/out" \
-v "$PWD:/apiprotos" \
-v "$GO_MOD_K8S_API:$GOPATH/pkg/mod/k8s.io/api" \
-v "$GO_MOD_K8S_APIMACHINERY:$GOPATH/pkg/mod/k8s.io/apimachinery" \
protoc-gen-doc --doc_opt=html,index.html -I "$GOPATH/pkg/mod/" -I /protobuf -I /apiprotos $proto

0 comments on commit 8da4db2

Please sign in to comment.