diff --git a/kube/completer.go b/kube/completer.go index 2384d53..5bc482f 100644 --- a/kube/completer.go +++ b/kube/completer.go @@ -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" @@ -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{