kubernetes / kops

Kubernetes Operations (kOps) - Production Grade k8s Installation, Upgrades and Management
https://kops.sigs.k8s.io/
Apache License 2.0
15.68k stars 4.61k forks source link

`kops completion --shell bash` yields index out of range panic #2841

Closed kemitche closed 7 years ago

kemitche commented 7 years ago

I. What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.):

"completion"

-------------BUG REPORT --------------------

  1. Fill in as much of the template below as you can. If you leave out information, we can't help you as well.

  2. What Kubernetes version are you running? use kubectl version

n/a

  1. What kops version are you running? use kops version

kops Version 1.6.2 (git-98ae12a) (1.6.2 from releases download on github)

I also built from source (Version 1.6.2 (git-a67ab0bc7)) and saw the same issue.

  1. What Environment are you running on? Distributor ID: Ubuntu Description: Ubuntu 17.04 Release: 17.04 Codename: zesty

  2. What commands did you execute (Please provide screenshot, if available) and what happened after commands executed?

└─ 1 $ ▶ kops completion --shell bash
panic: runtime error: index out of range

goroutine 1 [running]:
main.RunCompletion(0xc420a9a560, 0xc4203f3680, 0xc420a9ac80, 0x0, 0x2, 0x4835540, 0xc42000c018, 0xc420a8e4f0, 0x1, 0xc42000c618)
    /go/src/k8s.io/kops/cmd/kops/completion.go:128 +0x23b
main.NewCmdCompletion.func1(0xc4203f3680, 0xc420a9ac80, 0x0, 0x2)
    /go/src/k8s.io/kops/cmd/kops/completion.go:103 +0x71
k8s.io/kops/vendor/github.com/spf13/cobra.(*Command).execute(0xc4203f3680, 0xc420a9ab40, 0x2, 0x2, 0xc4203f3680, 0xc420a9ab40)
    /go/src/k8s.io/kops/vendor/github.com/spf13/cobra/command.go:603 +0x22b
k8s.io/kops/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x4954be0, 0x29dce00, 0x0, 0x0)
    /go/src/k8s.io/kops/vendor/github.com/spf13/cobra/command.go:689 +0x339
k8s.io/kops/vendor/github.com/spf13/cobra.(*Command).Execute(0x4954be0, 0x4984bc8, 0x0)
    /go/src/k8s.io/kops/vendor/github.com/spf13/cobra/command.go:648 +0x2b
main.Execute()
    /go/src/k8s.io/kops/cmd/kops/root.go:98 +0x9b
main.main()
    /go/src/k8s.io/kops/cmd/kops/main.go:25 +0x20
  1. What you expected to happen:

kops completion script emitted to stdout. Or, if --shell is incorrect, kops should print a usage message for the command.

  1. How can we to reproduce it (as minimally and precisely as possible):

Run kops completion --shell bash

  1. Anything else do we need to know:

After further examination, it looks like the current syntax expects kops completion bash, without a --shell flag. kops completion --help seems to need an update.

chrislovecnm commented 7 years ago

see the problem ... will have a PR shortly