Fake being in GOPATH when generating code.
What this PR does / why we need it:
This is a workaround for the code generators requiring $GOPATH to put output in the correct location.
Details in the issue.
Fixes
@@ -9,7 +9,8 @@ set -o pipefail
# it has been modified to enable caching.
export GO111MODULE=on
VERSION=$(go list -m all | grep k8s.io/code-generator | rev | cut -d"-" -f1 | cut -d" " -f1 | rev)
-CODE_GEN_DIR="hack/code-gen/$VERSION"
+REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel)}"
+CODE_GEN_DIR="${REPO_ROOT}/hack/code-gen/$VERSION"
if [[ -d ${CODE_GEN_DIR} ]]; then
echo "Using cached code generator version: $VERSION"
@@ -18,6 +19,15 @@ else
git -C "${CODE_GEN_DIR}" reset --hard "${VERSION}"
fi
+# Fake being in a $GOPATH until kubernetes fully supports modules
+# https://github.com/kudobuilder/kudo/issues/1252
+FAKE_GOPATH="$(mktemp -d)"
+trap 'chmod -R u+rwX ${FAKE_GOPATH} && rm -rf ${FAKE_GOPATH}' EXIT
+FAKE_REPOPATH="${FAKE_GOPATH}/src/github.com/kudobuilder/kudo"
+mkdir -p "$(dirname "${FAKE_REPOPATH}")" && ln -s "${REPO_ROOT}" "${FAKE_REPOPATH}"
+export GOPATH="${FAKE_GOPATH}"
+cd "${FAKE_REPOPATH}"
+
"${CODE_GEN_DIR}"/generate-groups.sh \
deepcopy \
github.com/kudobuilder/kudo/pkg/client \
