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"
|
2021-09-29 11:14:15 -06:00
|
|
|
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"
|
|
|
|
|
;;
|
2021-09-29 11:14:15 -06:00
|
|
|
gen-rbac)
|
|
|
|
|
validate "$HELM_ERR"
|
|
|
|
|
;;
|
2021-01-29 18:21:58 +01:00
|
|
|
*)
|
2021-09-29 11:14:15 -06: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
|