2014-06-06 19:40:48 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2015-05-13 15:59:04 -04:00
|
|
|
readonly reset=$(tput sgr0)
|
|
|
|
|
readonly red=$(tput bold; tput setaf 1)
|
|
|
|
|
readonly green=$(tput bold; tput setaf 2)
|
|
|
|
|
|
2015-05-13 01:47:24 -04:00
|
|
|
exit_code=0
|
2015-05-01 14:57:03 -04:00
|
|
|
|
2015-07-02 17:29:59 -04:00
|
|
|
echo -ne "Checking that it builds... "
|
|
|
|
|
if ! OUT=$("hack/build-go.sh" 2>&1); then
|
|
|
|
|
echo
|
|
|
|
|
echo "${red}${OUT}"
|
|
|
|
|
exit_code=1
|
|
|
|
|
else
|
|
|
|
|
echo "${green}OK"
|
|
|
|
|
fi
|
|
|
|
|
echo "${reset}"
|
|
|
|
|
|
2015-05-13 01:47:24 -04:00
|
|
|
echo -ne "Checking for files that need gofmt... "
|
|
|
|
|
files_need_gofmt=()
|
2015-05-01 14:57:03 -04:00
|
|
|
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v -e "third_party" -e "Godeps"))
|
|
|
|
|
for file in "${files[@]}"; do
|
2014-06-24 18:01:08 -04:00
|
|
|
# Check for files that fail gofmt.
|
2015-07-02 17:29:59 -04:00
|
|
|
diff="$(git show ":${file}" | gofmt -s -d 2>&1)"
|
2014-06-06 19:40:48 -04:00
|
|
|
if [[ -n "$diff" ]]; then
|
2014-11-19 19:05:55 -05:00
|
|
|
files_need_gofmt+=("${file}")
|
2014-06-06 19:40:48 -04:00
|
|
|
fi
|
2014-06-25 20:11:48 -04:00
|
|
|
done
|
|
|
|
|
|
2015-05-13 01:47:24 -04:00
|
|
|
if [[ "${#files_need_gofmt[@]}" -ne 0 ]]; then
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${red}ERROR!"
|
2015-05-13 01:47:24 -04:00
|
|
|
echo "Some files have not been gofmt'd. To fix these errors, "
|
|
|
|
|
echo "cut and paste the following:"
|
|
|
|
|
echo " gofmt -s -w ${files_need_gofmt[@]}"
|
|
|
|
|
exit_code=1
|
|
|
|
|
else
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${green}OK"
|
2015-05-13 01:47:24 -04:00
|
|
|
fi
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${reset}"
|
2015-05-13 01:47:24 -04:00
|
|
|
|
|
|
|
|
echo -ne "Checking for files that need boilerplate... "
|
2015-07-19 20:02:47 -04:00
|
|
|
out=($(hack/verify-boilerplate.sh))
|
|
|
|
|
if [[ $? -ne 0 ]]; then
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${red}ERROR!"
|
2015-05-13 01:47:24 -04:00
|
|
|
echo "Some files are missing the required boilerplate header"
|
|
|
|
|
echo "from hooks/boilerplate.txt:"
|
2015-07-19 20:02:47 -04:00
|
|
|
for f in "${out[@]}"; do
|
|
|
|
|
echo " ${f}"
|
2015-05-13 01:47:24 -04:00
|
|
|
done
|
|
|
|
|
exit_code=1
|
|
|
|
|
else
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${green}OK"
|
2015-05-13 01:47:24 -04:00
|
|
|
fi
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${reset}"
|
2015-05-13 01:47:24 -04:00
|
|
|
|
|
|
|
|
echo -ne "Checking for API descriptions... "
|
|
|
|
|
files_need_description=()
|
2014-11-19 19:05:55 -05:00
|
|
|
# Check API schema definitions for field descriptions
|
2015-05-01 14:10:50 -04:00
|
|
|
for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v.[^/]*/types\.go" | grep -v "third_party"); do
|
2014-11-19 19:05:55 -05:00
|
|
|
# Check for files with fields without description tags
|
2015-07-20 09:24:20 -04:00
|
|
|
descriptionless=$(hack/after-build/verify-description.sh "${file}")
|
2015-08-10 12:38:15 -04:00
|
|
|
if [[ "$descriptionless" != "" ]]; then
|
2014-11-19 19:05:55 -05:00
|
|
|
files_need_description+=("${file}")
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [[ "${#files_need_description[@]}" -ne 0 ]]; then
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${red}ERROR!"
|
2015-05-13 01:47:24 -04:00
|
|
|
echo "Some API files are missing the required field descriptions."
|
|
|
|
|
echo "Add description tags to all non-inline fields in the following files:"
|
2015-05-13 00:59:44 -04:00
|
|
|
for file in "${files_need_description[@]}"; do
|
2015-05-13 01:47:24 -04:00
|
|
|
echo " ${file}"
|
2015-05-13 00:59:44 -04:00
|
|
|
done
|
2015-05-13 01:47:24 -04:00
|
|
|
exit_code=1
|
|
|
|
|
else
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${green}OK"
|
2014-11-19 19:05:55 -05:00
|
|
|
fi
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${reset}"
|
2015-01-15 00:27:13 -05:00
|
|
|
|
2015-07-24 20:11:16 -04:00
|
|
|
echo -ne "Checking for links in API descriptions... "
|
2015-07-20 09:24:20 -04:00
|
|
|
if ! hack/after-build/verify-linkcheck.sh > /dev/null; then
|
2015-07-24 20:11:16 -04:00
|
|
|
echo "${red}ERROR!"
|
2015-07-28 00:06:01 -04:00
|
|
|
echo "Some links in pkg/api/.*types.go are outdated. They require a manual fix."
|
2015-07-24 20:11:16 -04:00
|
|
|
exit_code=1
|
|
|
|
|
else
|
|
|
|
|
echo "${green}OK"
|
|
|
|
|
fi
|
|
|
|
|
echo "${reset}"
|
|
|
|
|
|
2015-05-13 01:47:24 -04:00
|
|
|
echo -ne "Checking for docs that need updating... "
|
2015-07-20 09:24:20 -04:00
|
|
|
if ! hack/after-build/verify-generated-docs.sh > /dev/null; then
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${red}ERROR!"
|
2015-05-13 01:47:24 -04:00
|
|
|
echo "Some docs are out of sync between CLI and markdown."
|
|
|
|
|
echo "To regenerate docs, run:"
|
2015-07-20 09:24:20 -04:00
|
|
|
echo " hack/update-generated-docs.sh"
|
2015-05-13 01:47:24 -04:00
|
|
|
exit_code=1
|
|
|
|
|
else
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${green}OK"
|
2015-01-15 00:27:13 -05:00
|
|
|
fi
|
2015-05-13 15:59:04 -04:00
|
|
|
echo "${reset}"
|
2015-05-13 00:59:44 -04:00
|
|
|
|
2015-05-19 11:47:03 -04:00
|
|
|
echo -ne "Checking for conversions that need updating... "
|
2015-07-20 09:24:20 -04:00
|
|
|
if ! hack/after-build/verify-generated-conversions.sh > /dev/null; then
|
2015-05-19 11:47:03 -04:00
|
|
|
echo "${red}ERROR!"
|
|
|
|
|
echo "Some conversions functions need regeneration."
|
|
|
|
|
echo "To regenerate conversions, run:"
|
|
|
|
|
echo " hack/update-generated-conversions.sh"
|
|
|
|
|
exit_code=1
|
|
|
|
|
else
|
|
|
|
|
echo "${green}OK"
|
|
|
|
|
fi
|
|
|
|
|
echo "${reset}"
|
|
|
|
|
|
2015-05-13 09:52:53 -04:00
|
|
|
echo -ne "Checking for deep-copies that need updating... "
|
2015-07-20 09:24:20 -04:00
|
|
|
if ! hack/after-build/verify-generated-deep-copies.sh > /dev/null; then
|
2015-05-13 09:52:53 -04:00
|
|
|
echo "${red}ERROR!"
|
|
|
|
|
echo "Some deep-copy functions need regeneration."
|
|
|
|
|
echo "To regenerate deep-copies, run:"
|
|
|
|
|
echo " hack/update-generated-deep-copies.sh"
|
|
|
|
|
exit_code=1
|
|
|
|
|
else
|
|
|
|
|
echo "${green}OK"
|
|
|
|
|
fi
|
|
|
|
|
echo "${reset}"
|
|
|
|
|
|
2015-06-08 04:38:08 -04:00
|
|
|
echo -ne "Checking for swagger spec that need updating... "
|
2015-07-20 09:24:20 -04:00
|
|
|
if ! hack/after-build/verify-swagger-spec.sh > /dev/null; then
|
2015-06-08 04:38:08 -04:00
|
|
|
echo "${red}ERROR!"
|
|
|
|
|
echo "Swagger spec needs to be updated."
|
|
|
|
|
echo "To regenerate the spec, run:"
|
|
|
|
|
echo " hack/update-swagger-spec.sh"
|
|
|
|
|
exit_code=1
|
|
|
|
|
else
|
|
|
|
|
echo "${green}OK"
|
|
|
|
|
fi
|
|
|
|
|
echo "${reset}"
|
|
|
|
|
|
2015-07-02 17:29:59 -04:00
|
|
|
if [[ "${exit_code}" != 0 ]]; then
|
|
|
|
|
echo "${red}Aborting commit${reset}"
|
|
|
|
|
fi
|
|
|
|
|
exit ${exit_code}
|
2015-08-10 12:38:15 -04:00
|
|
|
|
|
|
|
|
# ex: ts=2 sw=2 et filetype=sh
|