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

kubectl powershell completion #613

Closed
rgembalik opened this issue Mar 14, 2019 · 24 comments · Fixed by kubernetes/kubernetes#103758
Closed

kubectl powershell completion #613

rgembalik opened this issue Mar 14, 2019 · 24 comments · Fixed by kubernetes/kubernetes#103758
Labels
area/kubectl kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@rgembalik
Copy link

FEATURE REQUEST
It would be great to see autocompletion support for PowerShell. Is it possible for Windows releases?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 12, 2019
@bergmeister
Copy link

bergmeister commented Jul 3, 2019

The following module offer tab completion of kubectl within PowerShell Core
https://github.com/felixfbecker/PSKubectl

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 2, 2019
@seans3
Copy link
Contributor

seans3 commented Aug 2, 2019

/remove-lifecycle rotten
/area kubectl
/sig cli
/kind feature

@k8s-ci-robot k8s-ci-robot added area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. kind/feature Categorizes issue or PR as related to a new feature. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Aug 2, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2019
@seans3
Copy link
Contributor

seans3 commented Oct 31, 2019

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 30, 2020
@bgshacklett
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 31, 2020
@RoguePointer80
Copy link

I use kubectl every day, and it would be a great enhancement to have a powershell-native module (PS core, of course! cross platform et al). Right now we are stuck with the outdated cmd shell. For example, instead of returning yaml or json string on the stdout, the cmdlet could return rich objects that we could interact with easily.

@bergmeister
Copy link

@RoguePointer80 This is what you look for: https://github.com/felixfbecker/PSKubectl

@mziyabo
Copy link

mziyabo commented Apr 23, 2020

If you're looking for kubectl auto-completion in PowerShell you can have a look at PSKubectlCompletion module- https://www.powershellgallery.com/packages/PSKubectlCompletion

@eddiezane
Copy link
Member

/priority backlog

@k8s-ci-robot k8s-ci-robot added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Jul 22, 2020
@kingdevnl
Copy link

It would be amazing if we can have the auto completion like on bash

For eg pod names. Namespaces etc

@MartinSGill
Copy link

I really like the way the WinGet team did it. I'm sure I've also seen this pattern elsewhere.

"complete" is a command on the cli tool itself, which handles the auto-completion. It can then we wrapped by any shell's auto-complete mechanism, will always be up-to-date with the application itself, and can probably re-use most of the code the cli tool already uses for determining commands.

It would also make the existing shell completions for BASH/ZSH simpler and easier to maintain, as they would now simply call the CLI itself. Also means the shell completions don't need to be updated when the CLI commands change.

Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)
        [Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
        $Local:word = $wordToComplete.Replace('"', '""')
        $Local:ast = $commandAst.ToString().Replace('"', '""')
        winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
            [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
        }
}

I presume the BASH completion function would become equally short, instead of the 13,000 lines it is now.

@kbirger
Copy link

kbirger commented Oct 1, 2020

There are two cool options listed in this issue, but I consider them both proofs of concept.

https://github.com/felixfbecker/PSKubectl requires you to use an entirely new command syntax, which is not desirable

https://www.powershellgallery.com/packages/PSKubectlCompletion is a good start, but does not support resource name completion as of yet (there's an open issue for it).

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 30, 2020
@marckhouzam
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 4, 2021
@marckhouzam
Copy link
Member

As information, the next release of Cobra, the library beneath kubectl, will provide support for powershell completion:
spf13/cobra#1208

@kingdevnl
Copy link

That's dope.

@marckhouzam
Copy link
Member

Cobra 1.1.3 has been released and provides full PowerShell completion support. Kubectl could start using it for commands and flags.

However, custom completions that are defined directly in kubectl (e.g., kubectl get [tab], kubectl describe pod [tab], etc) will only work for PowerShell if they are moved to Go completions which is done in kubernetes/kubernetes#96087

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 21, 2021
@AndrewSav
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 21, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 19, 2021
@mrjester888
Copy link

/remove-lifecycle stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.