-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Makefile: Create Version-Agnostic Symlinks for Specified Versioned Binaries #4013
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I will try to understand better your motivation here.
ignore for now, I need to give a better look
The last two pushes should fix upgrades failing due to the binary file already existing (or rather the symlink to it) and it will also ensure the correct binary is used when downgrading by replacing the symlink every time. |
GOBIN=$(LOCALBIN) go install $${package} ;\ | ||
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of remove sed
since it does not work always at the same way in linux and mac/
sed
is usually problematic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be done without the symlink stuff, in case this doesn't make it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have an alternative approach that avoids using symlinks and you believe it would be more suitable, please feel free to suggest it. The use of symlinks might not be very clear for beginner users and could cause some confusion. Otherwise, I think I am ok with
set -e; \ | ||
package=$(2)@$(3) ;\ | ||
echo "Downloading $${package}" ;\ | ||
rm -f $(1) || true ;\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we removing here? The symbolic link or binary?
If is the symbolic link 👍
I do not think that we should remove anything without an explicit request, OK, or demand from a user.
It is not a good practice/ux delete staff without the user knowledge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The symbolic link, otherwise the go install
will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @schrej,
Thank you for your time and collab on this one 🥇
Just one question here: https://github.com/kubernetes-sigs/kubebuilder/pull/4013/files#r1676137395
Otherwise, after the explanations I think I am OK with the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am OK with the changes proposed.
/lgtm
/approved
If you have a better approach or suggestion feel free to raise a follow up
It seems good to fly 🎉
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, schrej The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
While the new approach (we'll, new since I last used kubebuilder) finally does proper upgrades of tools, which is very nice, it makes it much harder to use the versioned tools in scripts that aren't called by the makefile, e.g. Tilt. (https://tilt.dev/)
This MR introduces symlinks to the latest version of the tools, which are updated whenever a new version is downloaded.
The Makefile also uses those symlinks to access the tools, which makes the
go-install-tool
function a bit simpler, getting rid of the sed replace.Details
This change does not remove the explicit versioning, and the versioned binaries will still exists in the bin folder. There will just be an additional symlink to the version that was installed last (the symlink is only created during installation, which could be changed to support downgrades to already installed versions).
Use cases:
It is helpful if you write scripts that use the binaries downloaded by the makefile. You can just use e.g.
bin/kustomize
and there is no need to adapt it to the version currently set in the makefile, and also no need to execute the script with the makefile to pass in the binary to use.The only relevant one probably is kustomize, but it should be the same behaviour for all of them.
Another use-case can be to point your IDE to your
bin/golangci-lint
binary to always use the version specified by the project.