Files
my-rook-config/tests/scripts/validate_modified_files.sh
T

51 lines
1.0 KiB
Bash
Raw Normal View History

2020-08-26 11:44:35 +02:00
#!/bin/bash
set -ex
#############
# VARIABLES #
#############
CODEGEN_ERR="found codegen files! please run 'make codegen' and update your PR"
MOD_ERR="changes found by mod.check. You may need to run make clean"
2021-03-26 15:48:18 +05:30
CRD_ERR="changes found by 'make crds'. please run 'make crds' locally and update your PR"
2021-04-19 14:01:11 +05:30
BUILD_ERR="changes found by make build', please commit your go.sum or other changed files"
HELM_ERR="changes found by 'make gen-rbac'. please run 'make gen-rbac' locally and update your PR"
2020-08-26 11:44:35 +02:00
#############
# FUNCTIONS #
#############
function validate(){
2021-01-29 18:21:58 +01:00
git=$(git status --porcelain)
for file in $git; do
if [ -n "$file" ]; then
echo "$1"
echo "$git"
git diff
exit 1
fi
done
2020-08-26 11:44:35 +02:00
}
########
# MAIN #
########
case "$1" in
2021-01-29 18:21:58 +01:00
codegen)
validate "$CODEGEN_ERR"
;;
modcheck)
validate "$MOD_ERR"
;;
crd)
validate "$CRD_ERR"
;;
2021-04-19 14:01:11 +05:30
build)
validate "$BUILD_ERR"
;;
gen-rbac)
validate "$HELM_ERR"
;;
2021-01-29 18:21:58 +01:00
*)
echo $"Usage: $0 {codegen|modcheck|crd|build|gen-rbac}"
2021-01-29 18:21:58 +01:00
exit 1
2020-08-26 11:44:35 +02:00
esac