verify-staging-meta-files.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env bash
  2. # Copyright 2018 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. # This script checks whether the expected metadata files (such as OWNERS and
  16. # LICENSE) exist under the `staging/src/k8s.io/*` directories.
  17. # Usage: `hack/verify-staging-meta-files.sh`.
  18. set -o errexit
  19. set -o nounset
  20. set -o pipefail
  21. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
  22. expected_filenames=(
  23. .github/PULL_REQUEST_TEMPLATE.md
  24. code-of-conduct.md
  25. LICENSE
  26. OWNERS
  27. README.md
  28. SECURITY_CONTACTS
  29. )
  30. exceptions=(
  31. client-go/README.md # client-go provides its own README
  32. )
  33. RESULT=0
  34. for full_repo_path in "${KUBE_ROOT}"/staging/src/k8s.io/*; do
  35. repo=$(basename "${full_repo_path}")
  36. for filename in "${expected_filenames[@]}"; do
  37. if echo " ${exceptions[*]} " | grep -F " ${repo}/${filename} " >/dev/null; then
  38. continue
  39. elif [ ! -f "${KUBE_ROOT}/staging/src/k8s.io/${repo}/${filename}" ]; then
  40. echo "staging/src/k8s.io/${repo}/${filename} does not exist and must be created"
  41. RESULT=1
  42. fi
  43. done
  44. done
  45. exit $RESULT