Documentation
¶
Index ¶
Constants ¶
const PluginDescriptorFilename = "plugin.yaml"
Variables ¶
var IncompleteError = fmt.Errorf("incomplete plugin descriptor: name, shortDesc and command fields are required")
Functions ¶
This section is empty.
Types ¶
type Description ¶
type Description struct {
Name string `json:"name"`
ShortDesc string `json:"shortDesc"`
LongDesc string `json:"longDesc,omitempty"`
Example string `json:"example,omitempty"`
Command string `json:"command"`
}
PluginDescription holds everything needed to register a plugin as a command. Usually comes from a descriptor file.
type DirectoryPluginLoader ¶
type DirectoryPluginLoader struct {
Directory string
}
DirectoryPluginLoader is a PluginLoader that loads plugin descriptions from a given directory in the filesystem. Plugins are located in subdirs under the loader "root", where each subdir must contain, at least, a plugin descriptor file called "plugin.yaml" that translates into a PluginDescription.
type ExecPluginRunner ¶
type ExecPluginRunner struct{}
ExecPluginRunner is a PluginRunner that uses Go's os/exec to run plugins.
type MultiPluginLoader ¶
type MultiPluginLoader []PluginLoader
MultiPluginLoader is a PluginLoader that can encapsulate multiple plugin loaders, a successful loading means every encapsulated loader was able to load without errors.
type Plugin ¶
type Plugin struct {
Description
Source
Context RunningContext `json:"-"`
}
Plugin is the representation of a CLI extension (plugin).
type PluginLoader ¶
type PluginLoader interface {
Load() (Plugins, error)
}
PluginLoader is capable of loading a list of plugin descriptions.
func PathFromEnvVarPluginLoader ¶
func PathFromEnvVarPluginLoader(envVarName string, subdirs ...string) PluginLoader
PathFromEnvVarPluginLoader is a PluginLoader that loads plugins from one or more directories specified by the provided env var name. In case the env var is not set, the PluginLoader just loads nothing. A list of subdirectories can be provided, which will be appended to each path specified by the env var.
func PluginsEnvVarPluginLoader ¶
func PluginsEnvVarPluginLoader() PluginLoader
PluginsEnvVarPluginLoader is a PluginLoader that loads plugins from one or more directories specified by the KUBECTL_PLUGINS_PATH env var.
func UserDirPluginLoader ¶
func UserDirPluginLoader() PluginLoader
UserDirPluginLoader is a PluginLoader that loads plugins from the "plugins" directory under the user's kubeconfig dir (usually "~/.kube/plugins/").
func XDGDataPluginLoader ¶
func XDGDataPluginLoader() PluginLoader
XDGDataPluginLoader is a PluginLoader that loads plugins from one or more directories specified by the XDG system directory structure spec in the XDG_DATA_DIRS env var, plus the "kubectl/plugins/" suffix. According to the spec, if XDG_DATA_DIRS is not set it defaults to "/usr/local/share:/usr/share".
type PluginRunner ¶
type PluginRunner interface {
Run(plugin *Plugin, ctx RunningContext) error
}
PluginRunner is capable of running a plugin in a given running context.
type RunningContext ¶
type RunningContext struct {
In io.Reader
Out io.Writer
ErrOut io.Writer
Args []string
Env []string
WorkingDir string
}
RunningContext holds the context in which a given plugin is running - the in, out, and err streams, arguments and environment passed to it, and the working directory.
type Source ¶
type Source struct {
Dir string `json:"-"`
DescriptorName string `json:"-"`
}
PluginSource holds the location of a given plugin in the filesystem.
type TolerantMultiPluginLoader ¶
type TolerantMultiPluginLoader []PluginLoader
TolerantMultiPluginLoader is a PluginLoader than encapsulates multiple plugins loaders, but is tolerant to errors while loading from them.