cmd

package
Version: v0.0.0-...-5f4265e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Overview

Provides the 'gear' binary extension mechanism and remote execution infrastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommand

func AddCommand(parent *cobra.Command, c *cobra.Command, local bool) *cobra.Command

func AddCommandExtension

func AddCommandExtension(ext CommandRegistration, local bool)

Register an extension to this server during init() or startup

func ExtendCommands

func ExtendCommands(parent *cobra.Command, local bool)

func Fail

func Fail(code int, format string, other ...interface{})

func GenerateId

func GenerateId() string

Types

type CliJobResponse

type CliJobResponse struct {
	// A response stream to output to.  Defaults to DevNull
	Output io.Writer
	// true if output should be captured rather than printed
	Gather bool

	// Data gathered during request parsing FIXME: move to marshal?
	Pending map[string]interface{}
	// Data gathered from the response
	Data interface{}
	// The error set on the response
	Error error
	// contains filtered or unexported fields
}

func (*CliJobResponse) Failure

func (s *CliJobResponse) Failure(e error)

func (*CliJobResponse) StreamResult

func (s *CliJobResponse) StreamResult() bool

func (*CliJobResponse) Success

func (s *CliJobResponse) Success(t jobs.ResponseSuccess)

func (*CliJobResponse) SuccessWithData

func (s *CliJobResponse) SuccessWithData(t jobs.ResponseSuccess, data interface{})

func (*CliJobResponse) SuccessWithWrite

func (s *CliJobResponse) SuccessWithWrite(t jobs.ResponseSuccess, flush, structured bool) io.Writer

func (*CliJobResponse) WritePending

func (s *CliJobResponse) WritePending(w io.Writer)

func (*CliJobResponse) WritePendingSuccess

func (s *CliJobResponse) WritePendingSuccess(name string, value interface{})

type CommandRegistration

type CommandRegistration func(parent *cobra.Command)

Register flags and commands underneath a parent Command

type Executor

type Executor struct {
	// An interface for converting requests into jobs.
	Transport transport.Transport
	// The set of destinations to act on.
	On Locators
	// Given a set of locators on the same server, create one
	// job that represents all ids.
	Group FuncBulk
	// Given a set of locators on the same server, create one
	// job per locator.
	Serial FuncSerial
	// The stream to output to, will be set to DevNull by default
	Output io.Writer
	// Optional: respond to successful calls
	OnSuccess FuncReact
	// Optional: respond to errors when they occur
	OnFailure FuncReact
}

An executor runs a number of local or remote jobs in parallel or sequentially. You must set either .Group or .Serial

func (Executor) Gather

func (e Executor) Gather() (data []interface{}, failures []error)

Invoke the appropriate job on each server and return the set of data

func (Executor) Stream

func (e Executor) Stream() (failures []error)

Stream responses from all servers to output

func (Executor) StreamAndExit

func (e Executor) StreamAndExit()

type FuncBulk

type FuncBulk func(...Locator) JobRequest

type FuncReact

type FuncReact func(*CliJobResponse, io.Writer, RequestedJob)

type FuncSerial

type FuncSerial func(Locator) JobRequest

type JobRequest

type JobRequest interface{}

type Locator

type Locator interface {
	// The location of this resource
	TransportLocator() transport.Locator
	// Two resources are identical if they have the same
	// identity value.
	Identity() string
}

func NewResourceLocator

func NewResourceLocator(t transport.Transport, defaultType ResourceType, value string) (Locator, error)

type Locators

type Locators []Locator

func NewHostLocators

func NewHostLocators(t transport.Transport, values ...string) (Locators, error)

func NewResourceLocators

func NewResourceLocators(t transport.Transport, defaultType ResourceType, values ...string) (Locators, error)

func (Locators) Group

func (locators Locators) Group() (remote []Locators)

Group resource locators by their transport location

type RequestedJob

type RequestedJob struct {
	Request JobRequest
	Job     jobs.Job
	Locator Locator
}

type ResourceLocator

type ResourceLocator struct {
	// The type of resource being referenced
	Type ResourceType
	// The identifier of the resource at this location
	Id string
	// A label representing a server (varies by transport)
	At transport.Locator
}

The resource on a server reachable via a transport.

func (*ResourceLocator) Identity

func (r *ResourceLocator) Identity() string

func (*ResourceLocator) TransportLocator

func (r *ResourceLocator) TransportLocator() transport.Locator

type ResourceLocators

type ResourceLocators []ResourceLocator

type ResourceType

type ResourceType string

Disambiguate resources with the same id via their type

func SplitTypeHostSuffix

func SplitTypeHostSuffix(value string) (res ResourceType, host string, suffix string, err error)

Given a command line string representing a resource, break it into type, host identity, and suffix

type ResourceValidator

type ResourceValidator interface {
	Type() ResourceType
}

Directories

Path Synopsis
The 'gear' binary variations for linux, darwin, and windows.
The 'gear' binary variations for linux, darwin, and windows.
The 'sti' binary.
The 'sti' binary.
The switchns binary - an executable for executing a process inside a running Docker container.
The switchns binary - an executable for executing a process inside a running Docker container.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL