Documentation
¶
Overview ¶
Package plugins loads user-defined commands from a small YAML file, letting d9c be extended with custom actions (like k9s plugins). Each plugin binds a name (invoked as ":name") and/or a key to a local command, scoped to a resource view, with ${PLACEHOLDER} substitution from the selected row.
Example d9c-plugins.yaml:
plugins:
- name: dive
key: ctrl+d
scope: images
description: Explore image layers with dive
command: dive
args: ["${ID}"]
- name: htop
scope: containers
command: docker
args: ["-H", "${HOST}", "exec", "-it", "${ID}", "htop"]
- name: df
scope: "*"
background: true # stream output to the console instead of a TTY
command: docker
args: ["-H", "${HOST}", "system", "df"]
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the plugins file location next to the running binary, falling back to the current directory if the executable path is unavailable.
Types ¶
type Plugin ¶
type Plugin struct {
Name string `yaml:"name"`
Key string `yaml:"key"`
Scope string `yaml:"scope"` // containers|images|networks|volumes|compose|hosts|* (default *)
Description string `yaml:"description"`
Command string `yaml:"command"`
Args []string `yaml:"args"`
// Background runs the command detached, streaming its output to the operation
// console; the default (false) hands the terminal over for an interactive TTY.
Background bool `yaml:"background"`
}
Plugin is a single user-defined action.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is an immutable collection of loaded plugins. All methods are nil-safe so callers can hold a nil *Set when no plugins are configured.
func Load ¶
Load reads and validates the plugins file at path. A missing file yields an empty set (not an error); malformed YAML or an invalid plugin is an error.
func New ¶
New builds a Set directly from already-validated plugins. Load is the usual entry point; New is handy for tests and programmatic configuration.