Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ignore loading context plugins with empty context (derailed/k9s#2651) #2714

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/config/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ func (p Plugins) Load(path string) error {
if err := p.load(AppPluginsFile); err != nil {
errs = errors.Join(errs, err)
}
if err := p.load(path); err != nil {
errs = errors.Join(errs, err)
// Don't load any configuration from a context path if the path comes
// empty because the current context is also empty.
if path != "" {
if err := p.load(path); err != nil {
errs = errors.Join(errs, err)
}
}

for _, dataDir := range xdg.DataDirs {
Expand Down
6 changes: 5 additions & 1 deletion internal/view/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ func pluginActions(r Runner, aa *ui.KeyActions) error {
})

path, err := r.App().Config.ContextPluginsPath()
if err != nil {
// The current context can be empty, and in that case the
// ContextPluginsPath() method will return an empty string and an error.
// In this particular case, the fact that there is no context plugin
// path if there is no context by itself is not really an error.
if err != nil && path != "" {
return err
}
pp := config.NewPlugins()
Expand Down