Skip to content

Commit

Permalink
fix #2492 (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed authored Jan 18, 2024
1 parent ecb2536 commit c76703a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion internal/dao/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ var stdGroups = []string{
"v1",
}

func (m ResourceMetas) clear() {
for k := range m {
delete(m, k)
}
}

// Meta represents available resource metas.
type Meta struct {
resMetas ResourceMetas
Expand Down Expand Up @@ -188,7 +194,7 @@ func (m *Meta) LoadResources(f Factory) error {
m.mx.Lock()
defer m.mx.Unlock()

m.resMetas = make(ResourceMetas, 100)
m.resMetas.clear()
if err := loadPreferred(f, m.resMetas); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/view/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,6 @@ func (a *App) switchContext(ci *cmd.Interpreter, force bool) error {
if err != nil {
return err
}
if err := a.command.Reset(a.Config.ContextAliasesPath(), true); err != nil {
return err
}
if cns, ok := ci.NSArg(); ok {
ct.Namespace.Active = cns
}
Expand All @@ -493,6 +490,9 @@ func (a *App) switchContext(ci *cmd.Interpreter, force bool) error {
log.Error().Err(err).Msg("config save failed!")
}
a.initFactory(ns)
if err := a.command.Reset(a.Config.ContextAliasesPath(), true); err != nil {
return err
}

log.Debug().Msgf("--> Switching Context %q -- %q -- %q", name, ns, a.Config.ActiveView())
a.Flash().Infof("Switching context to %q::%q", name, ns)
Expand Down
2 changes: 1 addition & 1 deletion internal/view/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewCommand(app *App) *Command {
func (c *Command) Init(path string) error {
c.alias = dao.NewAlias(c.app.factory)
if _, err := c.alias.Ensure(path); err != nil {
log.Error().Err(err).Msgf("command init failed!")
log.Error().Err(err).Msgf("Alias ensure failed!")
return err
}
customViewers = loadCustomViewers()
Expand Down

0 comments on commit c76703a

Please sign in to comment.