cmctl
cmctl copied to clipboard
Make the binary dynamically determine whether it is a kubectl plugin
fixes https://github.com/cert-manager/cmctl/issues/38
See https://krew.sigs.k8s.io/docs/developer-guide/develop/best-practices/
TODO: I would like to get some feedback on the kubectl cert-manager autocomplete functionality.
UPDATE: autocomplete works as expected, additional improvements can be made in a separate PR
This PR adds a new completion command based on @maelvls' instructions to make kubectl completion work (https://github.com/cert-manager/cert-manager/issues/4657): ./kubectl-cert-manager completion kubectl --help
Looks to work for me, help prints the correct binary and autocomplete works (assuming you have that set up as per https://github.com/cert-manager/cert-manager/issues/4657)
One thing we could do though, is if we detect the binary name, could we detect kubectl_complete-cert_manager also and remove the need for the script? This could be a follow up improvement, dont think that it should block this
I've tried it, I had to rename the binary after running go install since the go.mod module name ends with cmctl:
go install . && mv $(go env GOPATH)/bin/{cmctl,kubectl-cert_manager}
Installing the "completion" is... weird. It is a shim rather than a completion script. I think I prefer Adam's idea. With Adam's idea, instead of:
kubectl cert-manager completion kubectl >$(go env GOPATH)/bin/kubectl_complete-cert-manager
chmod +x $(go env GOPATH)/bin/kubectl_complete-cert-manager
It would be:
ln -s $(which kubectl-cert_manager) $(dirname $(which kubectl-cert_manager))/kubectl_complete-cert-manager
No script needs to be created, and completion kubectl is no longer necessary 👍 Although it would be good to have a note in the --help with a link that explains how to enable completion.
What do you think?
Installing the "completion" is... weird. It is a shim rather than a completion script. I think I prefer Adam's idea. What do you think?
I'll investigate if this is easily doable.
I propose that we improve the completion logic in a separate PR.
Looks good! We will probably need some docs ready for the release telling people how to install /lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: inteon
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [inteon]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment