From 0159dd51b80cd04776fe403c01f77310bd021067 Mon Sep 17 00:00:00 2001 From: Jeremy Bopp Date: Wed, 5 Mar 2025 19:57:56 -0600 Subject: [PATCH] chore: Install toolchain files to location provided in KUBEBUILDER_ASSETS if set (#7238) --- hack/toolchain.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hack/toolchain.sh b/hack/toolchain.sh index 9bf6dbc47c96..c701d962fa6d 100755 --- a/hack/toolchain.sh +++ b/hack/toolchain.sh @@ -2,7 +2,8 @@ set -euo pipefail K8S_VERSION="${K8S_VERSION:="1.29.x"}" -KUBEBUILDER_ASSETS="/usr/local/kubebuilder/bin" +KUBEBUILDER_ASSETS="${KUBEBUILDER_ASSETS:-/usr/local/kubebuilder/bin}" + main() { tools @@ -32,10 +33,12 @@ tools() { } kubebuilder() { - sudo mkdir -p ${KUBEBUILDER_ASSETS} - sudo chown "${USER}" ${KUBEBUILDER_ASSETS} + if ! mkdir -p ${KUBEBUILDER_ASSETS}; then + sudo mkdir -p ${KUBEBUILDER_ASSETS} + sudo chown $(whoami) ${KUBEBUILDER_ASSETS} + fi arch=$(go env GOARCH) - ln -sf "$(setup-envtest use -p path "${K8S_VERSION}" --arch="${arch}" --bin-dir="${KUBEBUILDER_ASSETS}")"/* ${KUBEBUILDER_ASSETS} + ln -sf $(setup-envtest use -p path "${K8S_VERSION}" --arch="${arch}" --bin-dir="${KUBEBUILDER_ASSETS}")/* ${KUBEBUILDER_ASSETS} find $KUBEBUILDER_ASSETS # Install latest binaries for 1.25.x (contains CEL fix)