update-generated-protobuf-dockerized.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Copyright 2015 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. source "${KUBE_ROOT}/hack/lib/init.sh"
  20. kube::golang::setup_env
  21. BINS=(
  22. cmd/libs/go2idl/go-to-protobuf
  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. gotoprotobuf=$(kube::util::find-binary "go-to-protobuf")
  36. # requires the 'proto' tag to build (will remove when ready)
  37. # searches for the protoc-gen-gogo extension in the output directory
  38. # satisfies import of github.com/gogo/protobuf/gogoproto/gogo.proto and the
  39. # core Google protobuf types
  40. PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
  41. "${gotoprotobuf}" \
  42. --proto-import="${KUBE_ROOT}/vendor" \
  43. --proto-import="${KUBE_ROOT}/third_party/protobuf" \
  44. $@