diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 08584848..123431d5 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -21,6 +21,9 @@ set -o pipefail cd "$(dirname "${0}")" GO_CMD=${1:-go} CODEGEN_PKG=${2:-../bin} +REPO_ROOT="$(git rev-parse --show-toplevel)" + +echo "GOPATH=$GOPATH" bash "${CODEGEN_PKG}/generate-groups.sh" \ "all" \ @@ -28,3 +31,14 @@ bash "${CODEGEN_PKG}/generate-groups.sh" \ sigs.k8s.io/jobset/api \ jobset:v1alpha2 \ --go-header-file ./boilerplate.go.txt + +# if client-go files were generated outside of repo root, attempt to move them to the repo root. +CLIENT_GO=$(find $GOPATH -regextype sed -regex ".*jobset.*client-go") +if [ -z "$CLIENT_GO" ]; then + echo "WARNING: generated client-go files were not found." +elif [ "$CLIENT_GO" -ne "$REPO_ROOT/client-go" ]; then + echo "moving generated files from $CLIENT_GO to $REPO_ROOT/client-go" + mv -f $CLIENT_GO $REPO_ROOT +fi + +