verify-util-pkg.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. # Copyright 2017 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. # verify-util-pkg.sh checks whether *.go except doc.go in pkg/util have been moved into
  16. # sub-pkgs, see issue #15634.
  17. set -o errexit
  18. set -o nounset
  19. set -o pipefail
  20. BASH_DIR=$(dirname "${BASH_SOURCE[0]}")
  21. find_go_files() {
  22. find . -maxdepth 1 -not \( \
  23. \( \
  24. -wholename './doc.go' \
  25. \) -prune \
  26. \) -name '*.go'
  27. }
  28. ret=0
  29. pushd "${BASH_DIR}" > /dev/null
  30. for path in $(find_go_files); do
  31. file=$(basename "$path")
  32. echo "Found pkg/util/${file}, but should be moved into util sub-pkgs." 1>&2
  33. ret=1
  34. done
  35. popd > /dev/null
  36. if [[ ${ret} -gt 0 ]]; then
  37. exit ${ret}
  38. fi
  39. echo "Util Package Verified."