checking for nil pointer in merge namespace (#2659)
parent
363e1405e7
commit
1a25109d25
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ func Test_contextMerge(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"no-namespace": {
|
||||
c1: NewContext(),
|
||||
c2: &Context{},
|
||||
e: NewContext(),
|
||||
},
|
||||
}
|
||||
|
||||
for k, u := range uu {
|
||||
|
|
|
|||
|
|
@ -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!")
|
||||
|
|
|
|||
Loading…
Reference in New Issue