update-munge-docs.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/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. 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. git_upstream=$(kube::util::git_upstream_remote_name)
  21. : ${git_upstream:="upstream"}
  22. kube::golang::setup_env
  23. make -C "${KUBE_ROOT}" WHAT=cmd/mungedocs
  24. kube::util::ensure-temp-dir
  25. kube::util::gen-analytics "${KUBE_ROOT}"
  26. mungedocs=$(kube::util::find-binary "mungedocs")
  27. "${mungedocs}" "--upstream=${git_upstream}" "--root-dir=${KUBE_ROOT}/docs/" \
  28. && ret=0 || ret=$?
  29. if [[ $ret -eq 1 ]]; then
  30. echo "${KUBE_ROOT}/docs/ requires manual changes. See preceding errors."
  31. exit 1
  32. elif [[ $ret -gt 1 ]]; then
  33. echo "Error running mungedocs."
  34. exit 1
  35. fi
  36. "${mungedocs}" "--upstream=${git_upstream}" \
  37. "--root-dir=${KUBE_ROOT}/examples/" && ret=0 || ret=$?
  38. if [[ $ret -eq 1 ]]; then
  39. echo "${KUBE_ROOT}/examples/ requires manual changes. See preceding errors."
  40. exit 1
  41. elif [[ $ret -gt 1 ]]; then
  42. echo "Error running mungedocs."
  43. exit 1
  44. fi
  45. "${mungedocs}" "--upstream=${git_upstream}" \
  46. "--skip-munges=unversioned-warning,analytics" \
  47. "--norecurse" \
  48. "--root-dir=${KUBE_ROOT}/" && ret=0 || ret=$?
  49. if [[ $ret -eq 1 ]]; then
  50. echo "${KUBE_ROOT}/ requires manual changes. See preceding errors."
  51. exit 1
  52. elif [[ $ret -gt 1 ]]; then
  53. echo "Error running mungedocs."
  54. exit 1
  55. fi
  56. # ex: ts=2 sw=2 et filetype=sh