operator-framework / kubectl-operator

Manage Kubernetes Operators from the command line
https://operatorframework.io/
Apache License 2.0
128 stars 37 forks source link

operator describe: don't panic when specified package name is not found #79

Closed joelanford closed 1 year ago

joelanford commented 1 year ago

What happens:

$ kubectl operator describe foo        
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/operator-framework/kubectl-operator/internal/cmd.newOperatorDescribeCmd.func1(0x14000160c80?, {0x1400011a7e0?, 0x1?, 0x1?})
        kubectl-operator/internal/cmd/operator_describe.go:51 +0xba4
github.com/spf13/cobra.(*Command).execute(0x14000160c80, {0x1400011a7a0, 0x1, 0x1})
        /Users/joe/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860 +0x4ac
github.com/spf13/cobra.(*Command).ExecuteC(0x14000142c80)
        /Users/joe/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x354
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/joe/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
github.com/operator-framework/kubectl-operator/internal/cmd.Execute()
        kubectl-operator/internal/cmd/root.go:16 +0x20
main.main()
        kubectl-operator/main.go:8 +0x1c

What I expect to happen (and what happens with this PR):

$ kubectl operator describe foo
packagemanifests.packages.operators.coreos.com "foo" not found

Follows up on #78

Signed-off-by: Joe Lanford joe.lanford@gmail.com

openshift-ci[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joelanford

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: - ~~[OWNERS](https://github.com/operator-framework/kubectl-operator/blob/main/OWNERS)~~ [joelanford] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment