Permalink
Browse files

add pkg/kubelet/hyper/api for hyperd grpc api

Signed-off-by: Yao Zengzeng <yaozengzeng@zju.edu.cn>
  • Loading branch information...
YaoZengzeng committed Aug 25, 2016
1 parent ad04b25 commit 341afb42bbfab68260e332aeb0aae83e26c38566
View
@@ -97,3 +97,5 @@ network_closure.sh
# Downloaded kubernetes binary release tar ball
kubernetes.tar.gz
+
+cmd/protoc-gen-gogo/protoc-gen-gogo
@@ -0,0 +1,43 @@
+/*
+Copyright 2015 The Kubernetes Authors All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// protoc-gen-go is a plugin for the Google protocol buffer compiler to generate
+// Go code. Run it by building this program and putting it in your path with
+// the name
+// protoc-gen-gogo
+// That word 'gogo' at the end becomes part of the option string set for the
+// protocol compiler, so once the protocol compiler (protoc) is installed
+// you can run
+// protoc --gogo_out=output_directory input_directory/file.proto
+// to generate Go bindings for the protocol defined by file.proto.
+// With that input, the output will be written to
+// output_directory/file.pb.go
+//
+// The generated code is documented in the package comment for
+// the library.
+//
+// See the README and documentation for protocol buffers to learn more:
+// https://developers.google.com/protocol-buffers/
+
+package main
+
+import (
+ "github.com/gogo/protobuf/vanity/command"
+)
+
+func main() {
+ command.Write(command.Generate(command.Read()))
+}
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Copyright 2016 The Kubernetes Authors All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+which protoc>/dev/null
+if [[ $? != 0 ]]; then
+ echo "Please install grpc from www.grpc.io"
+ exit 1
+fi
+
+KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
+KUBE_ROOT_ABS=$(cd ${KUBE_ROOT}; pwd)
+cd ${KUBE_ROOT_ABS}/cmd/protoc-gen-gogo
+go build
View
5 hack/install-protoc.sh 100644 → 100755
@@ -1,5 +1,6 @@
#!/bin/bash
-# Copyright 2016 The Kubernetes Authors.
+
+# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -26,4 +27,4 @@ curl -sSL https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0
unzip protoc-3.0.0-linux-x86_64.zip
sudo mv bin/protoc /usr/bin/protoc
-echo "protoc installed success."
+echo "protoc installed success."
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Copyright 2016 The Kubernetes Authors All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
+HYPERD_API_ROOT="${KUBE_ROOT}/pkg/kubelet/hyper/types"
+
+if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3.0."* ]]; then
+ echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and"
+ echo "install the platform appropriate Protobuf package for your OS: "
+ echo
+ echo " https://github.com/google/protobuf/releases"
+ echo
+ echo "WARNING: Protobuf changes are not being validated"
+ exit 1
+fi
+
+function cleanup {
+ rm -f ${HYPERD_API_ROOT}/types.pb.go.bak
+}
+
+trap cleanup EXIT
+
+hack/build-protoc-gen-gogo.sh
+export PATH=${KUBE_ROOT}/cmd/protoc-gen-gogo:$PATH
+protoc -I${HYPERD_API_ROOT} --gogo_out=plugins=grpc:${HYPERD_API_ROOT} ${HYPERD_API_ROOT}/types.proto
+echo "$(cat hack/boilerplate/boilerplate.go.txt ${HYPERD_API_ROOT}/types.pb.go)" > ${HYPERD_API_ROOT}/types.pb.go
+sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${HYPERD_API_ROOT}/types.pb.go
@@ -77,6 +77,8 @@ cluster/vagrant/provision-utils.sh: api_servers: '$(echo "$MASTER_IP" | sed -e
cluster/vagrant/provision-utils.sh: node_ip: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
cluster/vagrant/provision-utils.sh: runtime_config: '$(echo "$RUNTIME_CONFIG" | sed -e "s/'/''/g")'
cluster/vsphere/templates/salt-minion.sh: hostname_override: $(ip route get 1.1.1.1 | awk '{print $7}')
+cmd/protoc-gen-gogo/protoc-gen-gogo.go:// output_directory/file.pb.go
+cmd/protoc-gen-gogo/protoc-gen-gogo.go:// protoc --gogo_out=output_directory input_directory/file.proto
docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js: host.cloud_config_file = cloud_config;
docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js: host.cloud_config_file = cloud_config[n];
docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js: if (cloud_config instanceof Array) {
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# Copyright 2016 The Kubernetes Authors All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
+PROTO_ROOT=${KUBE_ROOT}/pkg/kubelet/hyper/types
+_tmp="${KUBE_ROOT}/_tmp"
+
+cleanup() {
+ rm -rf "${_tmp}"
+}
+
+trap "cleanup" EXIT SIGINT
+
+mkdir -p ${_tmp}
+cp ${PROTO_ROOT}/types.pb.go ${_tmp}
+
+ret=0
+hack/update-generated-hyperd-grpc-types.sh
+diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr ${_tmp}/types.pb.go ${PROTO_ROOT}/types.pb.go || ret=$?
+if [[ $ret -eq 0 ]]; then
+ echo "Generated hyperd grpc types from proto up to date."
+else
+ echo "Generated hyperd grpc types from proto is out of date. Please run hack/update-generated-hyperd-grpc-types.sh"
+ exit 1
+fi
Oops, something went wrong.

0 comments on commit 341afb4

Please sign in to comment.