pink

package module
v0.0.0-...-6165587 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: MIT Imports: 17 Imported by: 0

README

pink

Build Status Documentation

An extensible command line interface for curating and invoking tools.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DispatchCommand

func DispatchCommand(args []string, path []string, root string) (string, []string, bool, error)

DispatchCommand finds the manifest for the correct command, or instructs us to run "help". If neither case is appropriate, an error is returned.

func GetPluginsDir

func GetPluginsDir(root string) string

GetPluginsDir returns the default root of the plugins tree below a given root.

func Help

func Help(root string)

Help will list the plugins installed below a given root.

func RunFromManifest

func RunFromManifest(pluginD, path string, args []string) error

RunFromManifest reads a plugins manifest and then invokes it in line with the content of that manifest.

Types

type DockerConfig

type DockerConfig struct {
	ImageURL string `json:"image-url"`
	TTY      bool   `json:"bool"`
}

DockerConfig contains options for customizing the docker invoker.

type DockerInvoker

type DockerInvoker struct {
	Client *client.Client
	// contains filtered or unexported fields
}

DockerInvoker invokes a plugin as a docker container.

func NewDockerInvoker

func NewDockerInvoker(client *client.Client, stdout, stderr io.Writer) *DockerInvoker

NewDockerInvoker creates a configured DockerInvoker.

func (*DockerInvoker) Invoke

func (d *DockerInvoker) Invoke(ctx context.Context, m *Manifest, cfg *InvokerConfig) error

Invoke the docker container based on the given manifest and config.

type ExecutableInvoker

type ExecutableInvoker struct {
	PluginDir string
}

ExecutableInvoker invokes a plugin as an executable.

func (*ExecutableInvoker) Invoke

func (e *ExecutableInvoker) Invoke(ctx context.Context, m *Manifest, cfg *InvokerConfig) error

Invoke an executable described by the given manifest. The configuration can be used to pass args and environment variables to that executable.

type Invoker

type Invoker interface {
	Invoke(ctx context.Context, m *Manifest, cfg *InvokerConfig) error
}

Invoker invokes a plugin and passes it the given configuration.

type InvokerConfig

type InvokerConfig struct {
	Args []string
	Env  []string
}

InvokerConfig contains information passed to the invoked plugin.

type Manifest

type Manifest struct {
	Invoker string       `json:"invoker"`
	Exec    string       `json:"exec"`
	Docker  DockerConfig `json:"docker"`
	Command []string     `json:"command"`
}

A Manifest describes a plugin information.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads the file found at the given path and decodes it into a manifest. The file must be JSON formatted.

func (*Manifest) Invoke

func (m *Manifest) Invoke(ctx context.Context, pluginDir string, args []string) error

Invoke causes the manifests executable, or docker image to be run, as appropriate.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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