cmd

package
v0.0.0-...-aa49ab7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2014 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ForDaemon = "daemon"

Initializers that should be loaded when the daemon is loaded

View Source
const ForLocal = "local"

Initializers that should be used whenever a local command is run

Variables

This section is empty.

Functions

func AddCommand

func AddCommand(parent *cobra.Command, cmd *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 AddInitializer

func AddInitializer(init FuncInit, when ...string)

Register an initializer to be invoked and an optional list of conditions. If no conditions are passed the initializer is run whenever a command invokes cmd.Initialize()

func ExtendCommands

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

func Fail

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

func Initialize

func Initialize(when ...string) error

func LocatorsAreEqual

func LocatorsAreEqual(a, b Locator) bool

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 jobs.JobError
	// contains filtered or unexported fields
}

func (*CliJobResponse) Failure

func (s *CliJobResponse) Failure(e jobs.JobError)

func (*CliJobResponse) StreamResult

func (s *CliJobResponse) StreamResult() bool

func (*CliJobResponse) Success

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

func (*CliJobResponse) SuccessWithData

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

func (*CliJobResponse) SuccessWithWrite

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

func (*CliJobResponse) WriteClosed

func (s *CliJobResponse) WriteClosed() <-chan bool

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 ContainerLocator

type ContainerLocator struct {
	HostLocator
	Id containers.Identifier
}

func NewContainerLocator

func NewContainerLocator(value string) (*ContainerLocator, error)

func (*ContainerLocator) Identifier

func (r *ContainerLocator) Identifier() containers.Identifier

func (*ContainerLocator) Identity

func (r *ContainerLocator) Identity() string

func (*ContainerLocator) ResourceType

func (r *ContainerLocator) ResourceType() ResourceType

type Executor

type Executor struct {
	On []Locator
	// 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: specify an initializer for local execution
	LocalInit FuncInit
	// 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) jobs.Job

type FuncInit

type FuncInit func() error

func InitializeAll

func InitializeAll(funcs ...FuncInit) FuncInit

func LocalInitializers

func LocalInitializers(funcs ...FuncInit) FuncInit

Helper function for invoking local initializers.

type FuncReact

type FuncReact func(*CliJobResponse, io.Writer, interface{})

type FuncSerial

type FuncSerial func(Locator) jobs.Job

type GenericLocator

type GenericLocator struct {
	HostLocator
	Id   containers.Identifier
	Type ResourceType
}

func (*GenericLocator) Identifier

func (r *GenericLocator) Identifier() containers.Identifier

func (*GenericLocator) Identity

func (r *GenericLocator) Identity() string

func (*GenericLocator) ResourceType

func (r *GenericLocator) ResourceType() ResourceType

type HostLocator

type HostLocator struct {
	Host string
	Port port.Port
}

func NewHostLocator

func NewHostLocator(value string) (*HostLocator, error)

func (*HostLocator) BaseURL

func (r *HostLocator) BaseURL() *url.URL

func (*HostLocator) HostIdentity

func (r *HostLocator) HostIdentity() string

func (*HostLocator) Identity

func (r *HostLocator) Identity() string

func (*HostLocator) IsDefaultPort

func (r *HostLocator) IsDefaultPort() bool

func (*HostLocator) IsRemote

func (r *HostLocator) IsRemote() bool

func (*HostLocator) NewURI

func (h *HostLocator) NewURI() (*url.URL, error)

func (*HostLocator) ResolvedHostname

func (r *HostLocator) ResolvedHostname() string

func (*HostLocator) ResourceType

func (r *HostLocator) ResourceType() ResourceType

type Locator

type Locator interface {
	ResourceType() ResourceType
	IsRemote() bool
	Identity() string
	HostIdentity() string
}

func NewGenericLocator

func NewGenericLocator(defaultType ResourceType, value string) (Locator, error)

type Locators

type Locators []Locator

func NewContainerLocators

func NewContainerLocators(values ...string) (Locators, error)

func NewGenericLocators

func NewGenericLocators(defaultType ResourceType, values ...string) (Locators, error)

func NewHostLocators

func NewHostLocators(values ...string) (Locators, error)

func (Locators) Group

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

func (Locators) Has

func (locators Locators) Has(locator Locator) bool

type ResourceLocator

type ResourceLocator interface {
	Identifier() containers.Identifier
}

type ResourceType

type ResourceType string
const (
	LocalHostName                      = "local"
	ResourceTypeContainer ResourceType = "ctr"
)

Directories

Path Synopsis
An executable that can run as an agent for remote execution, make calls to a remote agent, or invoke commands locally.
An executable that can run as an agent for remote execution, make calls to a remote agent, or invoke commands locally.

Jump to

Keyboard shortcuts

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