cert-manager / cmctl

`cmctl` or `kubectl cert-manager` is the command line utility that makes cert-manager'ing easier.
https://cert-manager.io/docs/reference/cmctl/
Apache License 2.0
34 stars 8 forks source link

cmctl as kubectl plugin and shell completion #123

Closed abiwot closed 2 hours ago

abiwot commented 2 hours ago

How to get cmctl shell completion working when used as kubectl plugin

Trying to get the cmctl shell completion to work when installed as the kubectl plugin (kubectl cert-manager TAB). I think I need some clarification around exactly what needs to be done.

Environment:

kubectl shell completion steps:

  1. Run sudo apt install -y bash-completion
  2. Run echo "source <(kubectl completion bash)" >> $HOME/.bashrc
  3. Run source $HOME/.bashrc

Reproduce:

  1. Run OS=$(uname -s | tr A-Z a-z); ARCH=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/'); curl -fsSL -o cmctl https://github.com/cert-manager/cmctl/releases/latest/download/cmctl_${OS}_${ARCH}
  2. Run chmod +x cmctl
  3. Run sudo mv cmctl /usr/local/bin/kubectl-cert_manager
  4. Run kubectl cert-manager completion kubectl

OUTPUT:

#!/usr/bin/env sh
kubectl cert-manager __complete "$@"

Attempted:

  1. echo "source <(kubectl cert-manager completion kubectl)" >> $HOME/.bashrc
  2. kubectl cert-manager completion kubectl | sudo tee /etc/bash_completion.d/kubectl-cert_manager
  3. Rebooted host, started new shell, sourced .bashrc = all same error

ERROR:

error: requires at least 1 arg(s), only received 0
abiwot commented 2 hours ago

@dosu Step 2 is incorrect. There is no option kubectl cert-manager completion bash when cmctl is used as kubectl plugin. The only option is kubectl.

Even when this is corrected, the original error reported still exist.

abiwot commented 2 hours ago

@dosu Step 3 is incorrect. There is no option cmctl completion kubectl The only options when when /usr/local/bin/cmtl is used (not a kubectl plugin) is:

abiwot commented 2 hours ago

@dosu You made a good attempt to resolve this but you are referring to a solution that is already flagged as incorrect. It seems you are in a logical loop. You need to raise this issue to your "creator"

inteon commented 2 hours ago

Sorry for the bot, it does not work as expected. I removed it and its comments.

inteon commented 2 hours ago

The kubectl cert-manager completion kubectl --help command should provide you with the following instructions to setup shell completion:

To load completions:
$ kubectl cert-manager completion kubectl > kubectl_complete-cert_manager
$ sudo install kubectl_complete-cert_manager /usr/local/bin
...
abiwot commented 2 hours ago

@inteon Thanks for the clarification. I needed to go one level deeper with the --help command. I figured it was a user error. tx

abiwot commented 2 hours ago

Resolution: (see comment above) https://github.com/cert-manager/cmctl/issues/123#issuecomment-2363931312