Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ The plugin file content can be either a single plugin snippet, a collections of
A plugin is defined as follows:

* Shortcut option represents the key combination a user would type to activate the plugin. Valid values are [a-z], Shift-[A-Z], Ctrl-[A-Z].
* Override option make that the default action related to the shortcut will be overridden by the plugin
* Override option (`override: true`) replaces the built-in action bound to the same shortcut. Without this, a plugin whose shortcut collides with a built-in binding will be skipped and an error dialog is shown
* Confirm option (when enabled) lets you see the command that is going to be executed and gives you an option to confirm or prevent execution
* Description will be printed next to the shortcut in the k9s menu
* Scopes defines a collection of resources names/short-names for the views associated with the plugin. You can specify `all` to provide this shortcut for all views.
Expand Down
4 changes: 2 additions & 2 deletions internal/view/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func pluginActions(r Runner, aa *ui.KeyActions) error {
errs = errors.Join(errs, err)
continue
}
if _, ok := aa.Get(key); ok {
if existing, ok := aa.Get(key); ok {
if !pp.Plugins[k].Override {
errs = errors.Join(errs, fmt.Errorf("duplicate plugin key found for %q in %q", pp.Plugins[k].ShortCut, k))
errs = errors.Join(errs, fmt.Errorf("plugin %q shortcut %q conflicts with %q (use override: true to replace)", k, pp.Plugins[k].ShortCut, existing.Description))
continue
}
slog.Debug("Plugin overrode action shortcut",
Expand Down
25 changes: 15 additions & 10 deletions internal/view/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ import (
type Browser struct {
*Table

namespaces map[int]string
meta *metav1.APIResource
accessor dao.Accessor
contextFn ContextFunc
cancelFn context.CancelFunc
mx sync.RWMutex
updating bool
firstView atomic.Int32
namespaces map[int]string
meta *metav1.APIResource
accessor dao.Accessor
contextFn ContextFunc
cancelFn context.CancelFunc
mx sync.RWMutex
updating bool
firstView atomic.Int32
pluginErrShown atomic.Int32
}

// NewBrowser returns a new browser.
Expand Down Expand Up @@ -172,7 +173,8 @@ func (b *Browser) Start() {
}

b.Stop()
b.firstView.Store(0) // Reset first view counter on each start
b.firstView.Store(0)
b.pluginErrShown.Store(0)
b.GetModel().AddListener(b)
b.Table.Start()
b.CmdBuff().AddListener(b)
Expand Down Expand Up @@ -648,7 +650,10 @@ func (b *Browser) refreshActions() {

if err := pluginActions(b, b.Actions()); err != nil {
slog.Warn("Plugins load failed", slogs.Error, err)
b.app.Logo().Warn("Plugins load failed!")
if b.pluginErrShown.CompareAndSwap(0, 1) {
d := b.app.Styles.Dialog()
dialog.ShowError(&d, b.app.Content.Pages, err.Error())
}
}
if err := hotKeyActions(b, b.Actions()); err != nil {
slog.Warn("Hotkeys load failed", slogs.Error, err)
Expand Down