rook / kubectl-rook-ceph

Krew plugin to run kubectl commands with rook-ceph
Apache License 2.0
84 stars 28 forks source link

Auto completion for the plugin #70

Open subhamkrai opened 2 years ago

subhamkrai commented 2 years ago

With this pr https://github.com/kubernetes/kubernetes/pull/105867 which is supposed to present in kubectl v1.26 which will support krew plugins auto-completion. It will be good to have this in our plugin.

crabique commented 1 year ago

Does this imply completions on kubectl-command level (namespaces etc) or for subcommands as well, e.g. for rook-ceph rbd?

subhamkrai commented 1 year ago

@crabique Currently, auto-completion is not supported in rook-ceph plugin. But we'll support this soon

obnoxxx commented 1 year ago

@subhamkrai , in my local build, the build already has a completion command:

$ ./bin/kubectl-rook-ceph           
kubectl rook-ceph provides common management and troubleshooting tools for Ceph.

Usage:
  rook-ceph [command]

Available Commands:
  ceph            call a 'ceph' CLI command with arbitrary args
  completion      Generate the autocompletion script for the specified shell
  debug           Debug a deployment by scaling it down and creating a debug copy. This is supported for mons and OSDs only

$  ./bin/kubectl-rook-ceph completion
Generate the autocompletion script for rook-ceph for the specified shell.
See each sub-command's help for details on how to use the generated script.

Usage:
  rook-ceph completion [command]

Available Commands:
  bash        Generate the autocompletion script for bash
  fish        Generate the autocompletion script for fish
  powershell  Generate the autocompletion script for powershell
  zsh         Generate the autocompletion script for zsh

Flags:
  -h, --help   help for completion

Global Flags:
      --context string              Kubernetes context to use
      --kubeconfig string           kubernetes config path
  -n, --namespace string            Kubernetes namespace where CephCluster is created (default "rook-ceph")
      --operator-namespace string   Kubernetes namespace where rook operator is running

Use "rook-ceph completion [command] --help" for more information about a command.

maybe we have picked it up via an update of the kubernetes dependency automatically?

subhamkrai commented 1 year ago

@obnoxxx what we're looking with the issue to get auto completion support kubectl for kubectl plugins which currently not available.

What you have shared is coming from the go command line, using go today also we can have auto-completion that will work when directly using the binary.

obnoxxx commented 1 year ago

@subhamkrai I tried it locally and I can confirm that it currently works for neither the locally bilt kubectl-rook-ceph binary nor for the installed plugin kubectl rook-ceph

I am not quite sure yet what needs to be done to really enable it.

Skaronator commented 6 months ago

Unless I'm missing something: The auto-completion currently requires a configured rook which doesn't seem ideal:

kubectl rook-ceph completion bash                                                                                                                                                                                                 
Error: operator namespace 'rook-ceph' does not exist. namespaces "rook-ceph" not found
subhamkrai commented 6 months ago

@Skaronator I did auto-complete a long time back but only with local binary. But the auto-completion is not supported in krew yet.