Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 38d599d

Browse files
author
harry
authored
Merge pull request #114 from YaoZengzeng/grpc-init
Init grpc files and generate scripts
2 parents f1f7a97 + 341afb4 commit 38d599d

File tree

10 files changed

+4307
-0
lines changed

10 files changed

+4307
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ network_closure.sh
9797

9898
# Downloaded kubernetes binary release tar ball
9999
kubernetes.tar.gz
100+
101+
cmd/protoc-gen-gogo/protoc-gen-gogo

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ install:
2424
- go get github.com/tools/godep
2525
- go get github.com/mattn/goveralls
2626
- go get github.com/jstemmer/go-junit-report
27+
- ./hack/install-protoc.sh
2728
- ./hack/install-etcd.sh
2829
- travis_wait 30 ./hack/build-go.sh
2930
- travis_wait 30 godep go install ./...
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2015 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// protoc-gen-go is a plugin for the Google protocol buffer compiler to generate
18+
// Go code. Run it by building this program and putting it in your path with
19+
// the name
20+
// protoc-gen-gogo
21+
// That word 'gogo' at the end becomes part of the option string set for the
22+
// protocol compiler, so once the protocol compiler (protoc) is installed
23+
// you can run
24+
// protoc --gogo_out=output_directory input_directory/file.proto
25+
// to generate Go bindings for the protocol defined by file.proto.
26+
// With that input, the output will be written to
27+
// output_directory/file.pb.go
28+
//
29+
// The generated code is documented in the package comment for
30+
// the library.
31+
//
32+
// See the README and documentation for protocol buffers to learn more:
33+
// https://developers.google.com/protocol-buffers/
34+
35+
package main
36+
37+
import (
38+
"github.com/gogo/protobuf/vanity/command"
39+
)
40+
41+
func main() {
42+
command.Write(command.Generate(command.Read()))
43+
}

hack/build-protoc-gen-gogo.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
which protoc>/dev/null
22+
if [[ $? != 0 ]]; then
23+
echo "Please install grpc from www.grpc.io"
24+
exit 1
25+
fi
26+
27+
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
28+
KUBE_ROOT_ABS=$(cd ${KUBE_ROOT}; pwd)
29+
cd ${KUBE_ROOT_ABS}/cmd/protoc-gen-gogo
30+
go build

hack/install-protoc.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
which yum>/dev/null
18+
if [[ $? != 0 ]]; then
19+
sudo apt-get install -y unzip
20+
else
21+
sudo yum install -y unzip
22+
fi
23+
24+
# Install protoc
25+
cd /tmp
26+
curl -sSL https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip -o protoc-3.0.0-linux-x86_64.zip
27+
unzip protoc-3.0.0-linux-x86_64.zip
28+
sudo mv bin/protoc /usr/bin/protoc
29+
30+
echo "protoc installed success."
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
22+
HYPERD_API_ROOT="${KUBE_ROOT}/pkg/kubelet/hyper/types"
23+
24+
if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3.0."* ]]; then
25+
echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and"
26+
echo "install the platform appropriate Protobuf package for your OS: "
27+
echo
28+
echo " https://github.com/google/protobuf/releases"
29+
echo
30+
echo "WARNING: Protobuf changes are not being validated"
31+
exit 1
32+
fi
33+
34+
function cleanup {
35+
rm -f ${HYPERD_API_ROOT}/types.pb.go.bak
36+
}
37+
38+
trap cleanup EXIT
39+
40+
hack/build-protoc-gen-gogo.sh
41+
export PATH=${KUBE_ROOT}/cmd/protoc-gen-gogo:$PATH
42+
protoc -I${HYPERD_API_ROOT} --gogo_out=plugins=grpc:${HYPERD_API_ROOT} ${HYPERD_API_ROOT}/types.proto
43+
echo "$(cat hack/boilerplate/boilerplate.go.txt ${HYPERD_API_ROOT}/types.pb.go)" > ${HYPERD_API_ROOT}/types.pb.go
44+
sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${HYPERD_API_ROOT}/types.pb.go

hack/verify-flags/exceptions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ cluster/vagrant/provision-utils.sh: api_servers: '$(echo "$MASTER_IP" | sed -e
7777
cluster/vagrant/provision-utils.sh: node_ip: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
7878
cluster/vagrant/provision-utils.sh: runtime_config: '$(echo "$RUNTIME_CONFIG" | sed -e "s/'/''/g")'
7979
cluster/vsphere/templates/salt-minion.sh: hostname_override: $(ip route get 1.1.1.1 | awk '{print $7}')
80+
cmd/protoc-gen-gogo/protoc-gen-gogo.go:// output_directory/file.pb.go
81+
cmd/protoc-gen-gogo/protoc-gen-gogo.go:// protoc --gogo_out=output_directory input_directory/file.proto
8082
docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js: host.cloud_config_file = cloud_config;
8183
docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js: host.cloud_config_file = cloud_config[n];
8284
docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js: if (cloud_config instanceof Array) {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
22+
PROTO_ROOT=${KUBE_ROOT}/pkg/kubelet/hyper/types
23+
_tmp="${KUBE_ROOT}/_tmp"
24+
25+
cleanup() {
26+
rm -rf "${_tmp}"
27+
}
28+
29+
trap "cleanup" EXIT SIGINT
30+
31+
mkdir -p ${_tmp}
32+
cp ${PROTO_ROOT}/types.pb.go ${_tmp}
33+
34+
ret=0
35+
hack/update-generated-hyperd-grpc-types.sh
36+
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr ${_tmp}/types.pb.go ${PROTO_ROOT}/types.pb.go || ret=$?
37+
if [[ $ret -eq 0 ]]; then
38+
echo "Generated hyperd grpc types from proto up to date."
39+
else
40+
echo "Generated hyperd grpc types from proto is out of date. Please run hack/update-generated-hyperd-grpc-types.sh"
41+
exit 1
42+
fi

0 commit comments

Comments
 (0)