verify-api-reference-docs.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. # Verifies that api reference docs are up to date.
  16. set -o errexit
  17. set -o nounset
  18. set -o pipefail
  19. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  20. source "${KUBE_ROOT}/hack/lib/init.sh"
  21. kube::golang::setup_env
  22. API_REFERENCE_DOCS_ROOT="${KUBE_ROOT}/docs/api-reference"
  23. OUTPUT_DIR="${KUBE_ROOT}/_tmp/api-reference"
  24. mkdir -p ${OUTPUT_DIR}
  25. TMP_ROOT="${KUBE_ROOT}/_tmp"
  26. trap "rm -rf ${TMP_ROOT}" EXIT SIGINT
  27. # Generate API reference docs in tmp.
  28. "./hack/update-api-reference-docs.sh" "${OUTPUT_DIR}"
  29. echo "diffing ${API_REFERENCE_DOCS_ROOT} against freshly generated docs"
  30. ret=0
  31. diff -NauprB -I 'Last update' --exclude=*.md "${API_REFERENCE_DOCS_ROOT}" "${OUTPUT_DIR}" || ret=$?
  32. if [[ $ret -eq 0 ]]
  33. then
  34. echo "${API_REFERENCE_DOCS_ROOT} up to date."
  35. else
  36. echo "${API_REFERENCE_DOCS_ROOT} is out of date. Please run hack/update-api-reference-docs.sh"
  37. exit 1
  38. fi
  39. # ex: ts=2 sw=2 et filetype=sh