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

Enable shell completion descriptions for bash #113636

Merged
merged 1 commit into from Nov 8, 2022

Conversation

marckhouzam
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR enables descriptions for kubectl shell completion for the bash shell, just like is already supported for zsh, fish and powershell.

This support is transparently provided by Cobra. It was turned off for kubetl because of a bug with certain bash menu options which has been fixed by Cobra 1.3.0 which has been used by kubectl for a while now.

Before the PR:

bash-5.1$ kubectl a[tab][tab]
alpha          api-resources  apply          attach         autoscale
annotate       api-versions   argo           auth

bash-5.1$ kubectl --c[tab][tab]
--cache-dir              --client-certificate     --cluster
--certificate-authority  --client-key             --context

With the PR:

bash-5.1$ kubectl a[tab][tab]
alpha          (Commands for features in alpha)
annotate       (Update the annotations on a resource)
api-resources  (Print the supported API resources on the server)
api-versions   (Print the supported API versions on the server, in the form of "group/version")
apply          (Apply a configuration to a resource by file name or stdin)
argo           (The command argo is a plugin installed by the user)
attach         (Attach to a running container)
auth           (Inspect authorization)
autoscale      (Auto-scale a deployment, replica set, stateful set, or replication controller)

bash-5.1$ kubectl --c[tab][tab]
--cache-dir              (Default cache directory)
--certificate-authority  (Path to a cert file for the certificate authority)
--client-certificate     (Path to a client certificate file for TLS)
--client-key             (Path to a client key file for TLS)
--cluster                (The name of the kubeconfig cluster to use)
--context                (The name of the kubeconfig context to use)

Special notes for your reviewer:

Helm has been using this feature without issue since Helm 3.7.0 which has been released September 15, 2021.

However, in a possibly overly cautious approach, helm allows users to choose to disable completion descriptions for bash and all other shells as well. As for kubectl, it currently enables shell descriptions all the time for zsh, powershell and fish, so this PR does the same for bash.

Does this PR introduce a user-facing change?

Kubectl shell completions for the bash shell now include descriptions.

cc @brianpursley

Cobra provides support for completion descriptions for bash.
It was turned off because of a bug with certain bash menu options which
have been fixed by Cobra 1.3.0.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 4, 2022
@marckhouzam
Copy link
Member Author

/sig cli

@KnVerey
Copy link
Contributor

KnVerey commented Nov 7, 2022

/triage accepted
/priority important-longterm
/lgtm
/approve

I pulled down this branch and confirmed that the descriptions now work exactly as described. Thank you for the detailed PR description! 👌

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 7, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 7, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KnVerey, marckhouzam

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 7, 2022
@k8s-ci-robot k8s-ci-robot merged commit 56a0823 into kubernetes:master Nov 8, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Nov 8, 2022
@marckhouzam marckhouzam deleted the feat/compBashDesc branch November 8, 2022 00:14
@marckhouzam
Copy link
Member Author

Thanks for the quick merge @KnVerey !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants