update-generated-runtime-dockerized.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. # Copyright 2016 The Kubernetes Authors.
  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. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  19. KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/pkg/kubelet/api/v1alpha1/runtime"
  20. source "${KUBE_ROOT}/hack/lib/init.sh"
  21. kube::golang::setup_env
  22. BINS=(
  23. cmd/libs/go2idl/go-to-protobuf/protoc-gen-gogo
  24. )
  25. make -C "${KUBE_ROOT}" WHAT="${BINS[*]}"
  26. if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3.0."* ]]; then
  27. echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and"
  28. echo "install the platform appropriate Protobuf package for your OS: "
  29. echo
  30. echo " https://github.com/google/protobuf/releases"
  31. echo
  32. echo "WARNING: Protobuf changes are not being validated"
  33. exit 1
  34. fi
  35. function cleanup {
  36. rm -f ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go.bak
  37. }
  38. trap cleanup EXIT
  39. gogopath=$(dirname $(kube::util::find-binary "protoc-gen-gogo"))
  40. export PATH=$gogopath:$PATH
  41. protoc -I${KUBE_REMOTE_RUNTIME_ROOT} --gogo_out=plugins=grpc:${KUBE_REMOTE_RUNTIME_ROOT} ${KUBE_REMOTE_RUNTIME_ROOT}/api.proto
  42. echo "$(cat hack/boilerplate/boilerplate.go.txt ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go)" > ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go
  43. sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go