Skip to content

Commit

Permalink
Fake being in GOPATH when generating code. (#1253)
Browse files Browse the repository at this point in the history
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 #1252
  • Loading branch information
porridge authored Jan 15, 2020
1 parent 046bc4d commit ef36da2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion hack/update_codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 \
Expand Down

0 comments on commit ef36da2

Please sign in to comment.