Skip to content

Commit

Permalink
Fix panic
Browse files Browse the repository at this point in the history
## before
> ~ kube-prompt
panic: interface conversion: error is *url.Error, not *errors.StatusError

goroutine 1 [running]:
github.com/c-bata/kube-prompt/kube.NewCompleter(0x1ea2a40, 0xc0000fde00, 0xe656a23892ca10dd)
        /Users/xx/go/src/github.com/c-bata/kube-prompt/kube/completer.go:40 +0x486
main.main()
        /Users/xx/go/src/github.com/c-bata/kube-prompt/main.go:23 +0x37

## after
> ~ kube-prompt
error Get https://192.168.64.7:8443/api/v1/namespaces: dial tcp 192.168.64.7:8443: i/o timeout
  • Loading branch information
wzshiming committed Jan 6, 2020
1 parent fee61bc commit 423ae26
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kube/completer.go
Expand Up @@ -37,7 +37,7 @@ func NewCompleter() (*Completer, error) {

namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{})
if err != nil {
if err.(*errors.StatusError).Status().Code == 403 {
if statusError, ok := err.(*errors.StatusError); ok && statusError.Status().Code == 403 {
namespaces = nil
} else {
return nil, err
Expand Down

0 comments on commit 423ae26

Please sign in to comment.