diff --git a/internal/config/data/context.go b/internal/config/data/context.go index e4fa1c95..960a4230 100644 --- a/internal/config/data/context.go +++ b/internal/config/data/context.go @@ -53,9 +53,12 @@ func NewContextFromKubeConfig(ks KubeSettings) (*Context, error) { } func (c *Context) merge(old *Context) { - if old == nil { + if old == nil || old.Namespace == nil { return } + if c.Namespace == nil { + c.Namespace = NewNamespace() + } c.Namespace.merge(old.Namespace) } diff --git a/internal/config/data/context_int_test.go b/internal/config/data/context_int_test.go index 1a37ff99..b4a78b24 100644 --- a/internal/config/data/context_int_test.go +++ b/internal/config/data/context_int_test.go @@ -70,6 +70,11 @@ func Test_contextMerge(t *testing.T) { }, }, }, + "no-namespace": { + c1: NewContext(), + c2: &Context{}, + e: NewContext(), + }, } for k, u := range uu { diff --git a/internal/view/app.go b/internal/view/app.go index 055c95c8..c0c6c41e 100644 --- a/internal/view/app.go +++ b/internal/view/app.go @@ -466,7 +466,7 @@ func (a *App) switchContext(ci *cmd.Interpreter, force bool) error { return err } } - a.Flash().Errf("Using %q namespace", ns) + a.Flash().Infof("Using %q namespace", ns) if err := a.Config.Save(true); err != nil { log.Error().Err(err).Msg("config save failed!")