From cbd6dd3356aeaa0d53585214ff5a6f5d0ef45b9b Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Mon, 24 Aug 2020 15:48:34 -0500 Subject: [PATCH] Use a symlink instead of directly mounting into GOPATH. This supports CI better, where the original input dir isn't in GOPATH. Signed-off-by: Matt Moyer --- hack/lib/update-codegen.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hack/lib/update-codegen.sh b/hack/lib/update-codegen.sh index 9a3802b95..fa2f7ea38 100755 --- a/hack/lib/update-codegen.sh +++ b/hack/lib/update-codegen.sh @@ -18,10 +18,10 @@ if [[ -z "${CONTAINED:-}" ]]; then echo "generating code for ${kubeVersion} using ${CODEGEN_IMAGE}..." docker run --rm \ --env CONTAINED=1 \ - --volume "${ROOT}:/go/src/${BASE_PKG}" \ - --workdir "/go/src/${BASE_PKG}" \ + --volume "${ROOT}:/work" \ + --workdir "/work" \ "${CODEGEN_IMAGE}" \ - "/go/src/${BASE_PKG}/hack/lib/$(basename "${BASH_SOURCE[0]}")" \ + "/work/hack/lib/$(basename "${BASH_SOURCE[0]}")" \ "${kubeVersion}" \ | sed "s|^|${kubeVersion} > |" done @@ -35,6 +35,13 @@ if [[ "${#KUBE_VERSIONS[@]}" -ne 1 ]]; then exit 1 fi +# Link the root directory into GOPATH since that is where output ends up. +GOPATH_ROOT="${GOPATH}/src/${BASE_PKG}" +mkdir -p "$(dirname "${GOPATH_ROOT}")" +ln -s "${ROOT}" "${GOPATH_ROOT}" +ROOT="${GOPATH_ROOT}" +cd "${ROOT}" + # KUBE_VERSION is the full version (e.g., '1.19.0-rc.0'). KUBE_VERSION="${KUBE_VERSIONS[0]}" export KUBE_VERSION