verify-generated-docs.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. kube::golang::setup_env
  21. BINS=(
  22. cmd/gendocs
  23. cmd/genkubedocs
  24. cmd/genman
  25. cmd/genyaml
  26. federation/cmd/genfeddocs
  27. )
  28. make -C "${KUBE_ROOT}" WHAT="${BINS[*]}"
  29. kube::util::ensure-temp-dir
  30. kube::util::gen-docs "${KUBE_TEMP}"
  31. # Verify the list matches the expected list (diff should be empty)
  32. if [[ "$(diff ${KUBE_ROOT}/.generated_docs ${KUBE_TEMP}/.generated_docs)" != "" ]]; then
  33. echo "List of generated docs doesn't match a freshly built list. Please run hack/update-generated-docs.sh"
  34. exit 1
  35. fi
  36. # Verify the files in the repo all contain the boilerplate instead of the actual
  37. # content.
  38. while read file; do
  39. # Ignore .generated_docs-- it should not have the boilerplate!
  40. [[ "${file}" == ".generated_docs" ]] && continue
  41. # Search for "hack/generate-docs.sh" as a proxy for the boilerplate content,
  42. # since the munger adds a bunch of other stuff.
  43. if [[ "$(grep "hack/generate-docs.sh" "${KUBE_ROOT}/${file}")" == "" ]]; then
  44. echo "${file} doesn't seem to have the correct boilerplate content for an autogenerated file."
  45. echo "Please run hack/update-generated-docs.sh"
  46. exit 1
  47. fi
  48. done <"${KUBE_ROOT}/.generated_docs"