Skip to content

Commit

Permalink
Install toolchain files to location provided in KUBEBUILDER_ASSETS if…
Browse files Browse the repository at this point in the history
… set

Also use sudo only when necessary to create the location
  • Loading branch information
javanthropus committed Feb 21, 2025
1 parent 4201bc9 commit 84514b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hack/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 84514b7

Please sign in to comment.