verify-cli-conventions.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. # Copyright 2016 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 the description format of help message of kubectl command
  16. # is valid or not. And this checking is done for all kubectl sub-commands.
  17. # Usage: `hack/verify-cli-conventions.sh`.
  18. set -o errexit
  19. set -o nounset
  20. set -o pipefail
  21. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
  22. source "${KUBE_ROOT}/hack/lib/init.sh"
  23. kube::golang::setup_env
  24. BINS=(
  25. cmd/clicheck
  26. )
  27. make -C "${KUBE_ROOT}" WHAT="${BINS[*]}"
  28. clicheck=$(kube::util::find-binary "clicheck")
  29. if ! output=$($clicheck 2>&1)
  30. then
  31. echo "$output"
  32. echo
  33. echo "FAILURE: CLI is not following one or more required conventions."
  34. exit 1
  35. else
  36. echo "$output"
  37. echo
  38. echo "SUCCESS: CLI is following all tested conventions."
  39. fi