mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-08-26 10:58:38 +00:00
undo lists.go kubeconfig not found and also, add contect msg to lists.go
This commit is contained in:
parent
03be094573
commit
0e2ea151b6
@ -7,6 +7,7 @@ import (
|
||||
"facette.io/natsort"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/ahmetb/kubectx/internal/cmdutil"
|
||||
"github.com/ahmetb/kubectx/internal/kubeconfig"
|
||||
"github.com/ahmetb/kubectx/internal/printer"
|
||||
)
|
||||
@ -18,10 +19,18 @@ func (_ ListOp) Run(stdout, stderr io.Writer) error {
|
||||
kc := new(kubeconfig.Kubeconfig).WithLoader(kubeconfig.DefaultLoader)
|
||||
defer kc.Close()
|
||||
if err := kc.Parse(); err != nil {
|
||||
if cmdutil.IsNotFoundErr(err) {
|
||||
printer.Warning(stderr, "kubeconfig file not found")
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "kubeconfig error")
|
||||
}
|
||||
|
||||
ctxs := kc.ContextNames()
|
||||
if ctxs == nil {
|
||||
err := printer.Warning(stderr, "No kubectl context found")
|
||||
return errors.Wrap(err, "kubeconfig error")
|
||||
}
|
||||
natsort.Sort(ctxs)
|
||||
|
||||
cur := kc.GetCurrentContext()
|
||||
|
Loading…
Reference in New Issue
Block a user