Skip to content
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

feature: add bash completion for plugin mode of kubectl ctx and kubectl ns #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RouxAntoine
Copy link

@RouxAntoine RouxAntoine commented Feb 6, 2023

if added to PATH and name kubectl_complete-ns and kubectl_complete-ctx these two script provide completion for ns and ctx cli in kubectl plugin mode

if this pull request is good to merge i could made another one on krew-index project to adapt the two manifest like this :

apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
  name: ns
spec:
  homepage: https://github.com/ahmetb/kubectx
  shortDescription: Switch between Kubernetes namespaces
  version: v0.9.4
  description: |
    Also known as "kubens", a utility to set your current namespace and switch
    between them.
  caveats: |
    If fzf is installed on your machine, you can interactively choose
    between the entries using the arrow keys, or by fuzzy searching
    as you type.
    To enable completion run add "$KREW_ROOT/store/ns/v0.9.4/completion/" to your PATH
  platforms:
  - selector:
      matchExpressions:
      - key: os
        operator: In
        values:
        - darwin
        - linux
    uri: https://github.com/ahmetb/kubectx/archive/v0.9.4.tar.gz
    sha256: e50b72a37d01cc4b2c7d51b8f2167de518031b0c013bcb0b82c036d5ad1d1926
    bin: kubens
    files:
    - from: kubectx-*/kubens
      to: .
    - from: kubectx-*/LICENSE
      to: .
    - from: kubectx-*/completion/plugins/kubectl_complete-ns
      to: completion

ps : maybe some change should be done to made this bash agnostic

…tl ns

if added to PATH and name `kubectl_complete-ns` and `kubectl_complete-ctx` these two script provide
completion for ns and ctx cli in kubectl plugin mode
@ahmetb
Copy link
Owner

ahmetb commented Feb 6, 2023

Nice, but I'm trying to see if we can provide a straightforward way in krew manifests to let plugins configure how their binary is linked for completions.

For kubectx, since we're moving away from bash implementations to Go based implementations, completions might make sense to implement as a hidden subcommand. It might take me a while to get back to this.

@RouxAntoine
Copy link
Author

kubectl completion for plugin call a binary named kubectl_complete-<pluginName> so i think hidden command would not work. But yes maybe a go binary is better to benefit of classical application function.

I thought of another solution for link completion in krew with existing manifest but it doesn't work. This solution was to create link from $KREW_ROOT/store/kubectl_complete-<pluginName> to $KREW_ROOT/bin/ but krew create only one link currently. Feel free to refuse this pull request i do this more for me than for particular contribution 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants