update.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env bash
  2. # Copyright 2014 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. # A single script that runs a predefined set of update-* scripts, as they often go together.
  16. set -o errexit
  17. set -o nounset
  18. set -o pipefail
  19. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
  20. source "${KUBE_ROOT}/hack/lib/init.sh"
  21. # If called directly, exit.
  22. if [[ "${CALLED_FROM_MAIN_MAKEFILE:-""}" == "" ]]; then
  23. echo "ERROR: $0 should not be run directly." >&2
  24. echo >&2
  25. echo "Please run this command using \"make update\""
  26. exit 1
  27. fi
  28. SILENT=${SILENT:-true}
  29. ALL=${FORCE_ALL:-false}
  30. trap 'exit 1' SIGINT
  31. if ${SILENT} ; then
  32. echo "Running in silent mode, run with SILENT=false if you want to see script logs."
  33. fi
  34. if ! ${ALL} ; then
  35. echo "Running in short-circuit mode; run with FORCE_ALL=true to force all scripts to run."
  36. fi
  37. BASH_TARGETS="
  38. update-generated-protobuf
  39. update-codegen
  40. update-generated-runtime
  41. update-generated-device-plugin
  42. update-generated-api-compatibility-data
  43. update-generated-docs
  44. update-generated-swagger-docs
  45. update-openapi-spec
  46. update-bazel
  47. update-gofmt"
  48. for t in ${BASH_TARGETS}; do
  49. echo -e "${color_yellow:?}Running ${t}${color_norm:?}"
  50. if ${SILENT} ; then
  51. if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then
  52. echo -e "${color_red:?}Running ${t} FAILED${color_norm}"
  53. if ! ${ALL}; then
  54. exit 1
  55. fi
  56. fi
  57. else
  58. if ! bash "${KUBE_ROOT}/hack/${t}.sh"; then
  59. echo -e "${color_red}Running ${t} FAILED${color_norm}"
  60. if ! ${ALL}; then
  61. exit 1
  62. fi
  63. fi
  64. fi
  65. done
  66. echo -e "${color_green:?}Update scripts completed successfully${color_norm}"