diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 3e9e7df8b..2f9c32083 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -26,3 +26,17 @@ ${SEDNA_ROOT}/hack/generate-groups.sh "deepcopy,client,informer,lister" \ ${SEDNA_GO_PACKAGE}/pkg/client ${SEDNA_GO_PACKAGE}/pkg/apis \ "sedna:v1alpha1" \ --go-header-file ${SEDNA_ROOT}/hack/boilerplate/boilerplate.generatego.txt + +# Check if Sedna home is different from the standard directory where GO projects are located +if ! [[ "${GOPATH}/src/${SEDNA_GO_PACKAGE}/" -ef "${SEDNA_ROOT}/" ]]; then + # Copy generated code into SEDNA_ROOT + echo "Warning: ${SEDNA_ROOT} not included in $GOPATH which is required by code-gen" + echo "Moving generated code from ${GOPATH}/src/${SEDNA_GO_PACKAGE}/pkg/ to ${SEDNA_ROOT}/" + rsync -a ${GOPATH}/src/${SEDNA_GO_PACKAGE}/pkg/{client,apis} ${SEDNA_ROOT}/pkg + if [ $? -eq 0 ]; then + echo "Copy successful!" + rm -rf ${GOPATH}/src/${SEDNA_GO_PACKAGE}/pkg/{client,apis} + else + echo "Error during copy of the generated code!" >&2 + fi +fi \ No newline at end of file