Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add secret and namespace completion (requires kubectl 1.26) #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maelvls
Copy link

@maelvls maelvls commented Feb 3, 2023

For this to work, you will need kubectl 1.26 and a shim that you can create with the following command:

cat <<'EOF' >~/go/bin/kubectl_complete-view_secret
#!/bin/bash
kubectl view-secret __complete "$@"
EOF
chmod u+x ~/go/bin/kubectl_complete-view_secret

See: kubernetes/kubernetes#105867

Closes #3

For this to work, you will need kubectl 1.26 and a shim that you can
create with the following command:

cat <<'EOF' >~/bin/kubectl_complete-view_secret && chmod u+x ~/bin/kubectl_complete-view_secret
kubectl view-secret __complete "$@"
EOF

See: kubernetes/kubernetes#105867
@maelvls maelvls requested a review from elsesiy as a code owner February 3, 2023 15:07
Copy link
Owner

@elsesiy elsesiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @maelvls, do you mind adding some tests as well?

@@ -191,3 +193,167 @@ func ProcessSecret(outWriter, errWriter io.Writer, secret map[string]interface{}

return nil
}

func getNamespaces(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like toComplete is unused

return nil, cobra.ShellCompDirectiveNoFileComp
}

func getSecrets(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args is unsed, can we ignore _ it?

@sharkymcdongles
Copy link

I built your version and tested, but it doesn't seem to pick up the script or work. I am using 1.27.X

@elsesiy
Copy link
Owner

elsesiy commented Aug 15, 2024

I took a slightly different approach in #47 allowing you to interactively select the secret (not the namespace yet). I might add proper completion support at some point after I receive some feedback on the current ergonomics

@pimvandenbroek
Copy link

Hi, the addition to interactively select the secret is really great. However, one of our namespaces has more than 3000 secrets. Scrolling through them in a list isn't working. Tab completion would really be welcome in this case. Hopefully it will still be added!

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

Successfully merging this pull request may close these issues.

Add bash completion support
4 participants