update.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-docs
  43. update-generated-swagger-docs
  44. update-openapi-spec
  45. update-bazel
  46. update-gofmt"
  47. for t in ${BASH_TARGETS}; do
  48. echo -e "${color_yellow:?}Running ${t}${color_norm:?}"
  49. if ${SILENT} ; then
  50. if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then
  51. echo -e "${color_red:?}Running ${t} FAILED${color_norm}"
  52. if ! ${ALL}; then
  53. exit 1
  54. fi
  55. fi
  56. else
  57. if ! bash "${KUBE_ROOT}/hack/${t}.sh"; then
  58. echo -e "${color_red}Running ${t} FAILED${color_norm}"
  59. if ! ${ALL}; then
  60. exit 1
  61. fi
  62. fi
  63. fi
  64. done
  65. echo -e "${color_green:?}Update scripts completed successfully${color_norm}"