Skip to content

Commit

Permalink
Merge pull request #70 from c-bata/continue-if-cannot-list-namespace
Browse files Browse the repository at this point in the history
Continue if we cannot list namespace
  • Loading branch information
c-bata authored Dec 2, 2019
2 parents 1f934f9 + f0c1671 commit dcc18ee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kube/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/c-bata/go-prompt"
"github.com/c-bata/go-prompt/completer"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -36,7 +37,11 @@ func NewCompleter() (*Completer, error) {

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

return &Completer{
Expand Down

0 comments on commit dcc18ee

Please sign in to comment.