chore: Install toolchain files to location provided in KUBEBUILDER_ASSETS if set #7238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also use sudo only when necessary to create the location
Fixes #N/A
Description
This allows the installation of toolchain files to an arbitrary path by setting the KUBEBUILDER_ASSETS environment variable. This was done in order to avoid the use of sudo in order to create and use a system path. Backward compatibility with the original method is preserved.
How was this change tested?
I ran make toolchain both with and without setting the KUBEBUILDER_ASSETS environment variable. Without it set, the default location of /usr/local/kubebuilder/bin was used and I was prompted for my password by sudo. With it set to a path under my home directory, the indicated path was created without needing sudo, and all toolchain content was copied into place.
I then ran make test with KUBEBUILDER_ASSETS set to the path in my home directory and /usr/local/kubebuilder deleted to prove that everything still works.
Does this change impact docs?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.