plugin

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package plugins provides support for creating extensible CLIs

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPluginNotFound = errors.New("plugin not found")
	ErrPluginInvalid  = errors.New("invalid plugin")

	Prefix = "kubefaas-"
)

Functions

func Exec

func Exec(md *Metadata, args []string) error

Exec executes the plugin using the provided args. All input and output is redirected to stdin, stdout, and stderr.

func FindAll

func FindAll() map[string]*Metadata

FindAll searches the machine for all plugins currently present.

func SearchRegistries

func SearchRegistries(cmd string) (string, bool)

SearchRegistries will search (remote) registries for the presence of the command. For now we only use the builtinRegistry

Types

type Metadata

type Metadata struct {
	Name    string   `json:"name,omitempty"`
	Version string   `json:"version,omitempty"`
	Aliases []string `json:"aliases,omitempty"`
	Usage   string   `json:"usage,omitempty"`
	Path    string   `json:"path,omitempty"`
}

ObjectMeta contains the metadata of a plugin. The only metadata that is guaranteed to be non-empty is the path and Name. All other fields are considered optional.

func Find

func Find(pluginName string) (*Metadata, error)

Find searches the machine for the given plugin, returning the metadata of the plugin. The only metadata that is guaranteed to be non-empty is the path and Name. All other fields are considered optional. If found it returns the plugin, otherwise it returns ErrPluginNotFound if the plugin was not found.

func (*Metadata) AddAlias

func (md *Metadata) AddAlias(alias string)

func (*Metadata) HasAlias

func (md *Metadata) HasAlias(needle string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL