update-generated-protobuf-dockerized.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env 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[0]}")/..
  19. source "${KUBE_ROOT}/hack/lib/init.sh"
  20. kube::golang::setup_env
  21. BINS=(
  22. vendor/k8s.io/code-generator/cmd/go-to-protobuf
  23. vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo
  24. )
  25. make -C "${KUBE_ROOT}" WHAT="${BINS[*]}"
  26. if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; 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. while IFS=$'\n' read -r line; do
  37. APIROOTS+=( "$line" );
  38. done <<< "${1}"
  39. shift
  40. # requires the 'proto' tag to build (will remove when ready)
  41. # searches for the protoc-gen-gogo extension in the output directory
  42. # satisfies import of github.com/gogo/protobuf/gogoproto/gogo.proto and the
  43. # core Google protobuf types
  44. PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
  45. "${gotoprotobuf}" \
  46. --proto-import="${KUBE_ROOT}/vendor" \
  47. --proto-import="${KUBE_ROOT}/third_party/protobuf" \
  48. --packages="$(IFS=, ; echo "${APIROOTS[*]}")" \
  49. --go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
  50. "$@"