app

package
v3.11.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 11, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartPhaseStartup = iota
	StartPhaseInitPlugins
	StartPhaseInitManager
	StartPhaseEventBeforeInstance
	StartPhaseEventWithInstance
	StartPhaseInstanceRunning
	StartPhaseEventAfterInstance
	StartPhaseShutdown
)

The order here *must* match the actual order that things are started

Variables

View Source
var (
	ErrNoSuchInstance         = errors.New("No such instance")
	ErrSingleInstanceArg      = errors.New("Must provide a single instance as the first argument")
	ErrFailedToAddPluginFlags = errors.New("Failed to add flags from plugin")
	ErrNotInContainer         = errors.New("Not in Docker container")
	ErrFailedEventPlugin      = errors.New("Failed to execute event plugin")
)
View Source
var DockerClient *docker.Client

Functions

func DockerCopy

func DockerCopy(instance *iscenv.ISCInstance, instancePath, localPath string) error

func DockerExec

func DockerExec(instance *iscenv.ISCInstance, interactive bool, commandAndArgs ...string) error

func DockerLogs

func DockerLogs(instance *iscenv.ISCInstance, since int64, tail string, follow bool, outputStream io.Writer) error

Retrieve the logs from only this start run DockerLogs will retrieve logs from a docker container If follow is true, the logs will be followed since is the unix time from which logs should be retrieved tail is the string value to pass to docker to determine the number of lines to tail. It should be either "all" or a string representation of the number of lines. Will return any error encountered

func DockerPort

func DockerPort(port iscenv.ContainerPort) docker.Port

func DockerPortBinding

func DockerPortBinding(port int64, portOffset int64) []docker.PortBinding

func DockerPull

func DockerPull(image, tag string) error

func DockerRemove

func DockerRemove(instance *iscenv.ISCInstance) error

func DockerRepoLogger

func DockerRepoLogger(repo string) *log.Entry

func DockerStart

func DockerStart(opts DockerStartOptions) (id string, err error)

Ensure that a container exists and is started. Returns the ID of the started container or an error

func EnsureWithinContainer

func EnsureWithinContainer(commandName string) error

func ErrorLogger

func ErrorLogger(logger log.FieldLogger, err error) *log.Entry

Will evaluate an error for known error types and return a logger with the appropriate fields pulled from that type of error.

func FileExists

func FileExists(path string) bool

func FindInstance

func FindInstance(instanceName string) *iscenv.ISCInstance

func FindInstanceAndLogger

func FindInstanceAndLogger(instanceName string) (*iscenv.ISCInstance, *log.Entry)

func GetContainerForInstance

func GetContainerForInstance(instance *iscenv.ISCInstance) (*docker.Container, error)

func GetDocker0InterfaceIP

func GetDocker0InterfaceIP() (string, error)

func GetDockerBindingPort

func GetDockerBindingPort(bindings []docker.PortBinding) (iscenv.ContainerPort, error)

Assumes a single binding

func GetInstanceStartTime

func GetInstanceStartTime(instance *iscenv.ISCInstance) (time.Time, error)

func GetInstances

func GetInstances() iscenv.ISCInstances

GetInstances will return a list of available ISC product Instances. This function will panic in the case that it cannot list the containers from Docker. Normally, these kinds of abrupt exits should be avoided outside of the actual executable command portions of the code. However, in this case the extreme nature of the failure, the rarity of occurrence, and the large amount of error handling that would need to be added throughout the code without the exit seems to justify its existence.

func InstanceLogger

func InstanceLogger(instance *iscenv.ISCInstance) *log.Entry

func InstanceLoggerArgs

func InstanceLoggerArgs(instanceName, instanceID string) *log.Entry

Return an instance logger with the values as args

func IsUserRoot

func IsUserRoot() error

func NewRawTTYStdin

func NewRawTTYStdin() (tty *rawTTYStdin, err error)

func PluginLogger

func PluginLogger(id, method, path string) *log.Entry

func Relog

func Relog(plog log.FieldLogger, preserveTimestamp bool, rlog map[string]interface{})

Relog will relog a single log message that has been Unmarshaled into a map[string]interface{} extraFields contains additional fields you wish to add to the log output. These will overwrite any fields from the original log message. preserveTimestamps will use the timestamps from the original log messages instead of the current time

func RelogStream

func RelogStream(plog log.FieldLogger, preserveTimestamp bool, r io.Reader)

RelogStream will given a JSON log stream, relog all of the message into the current process extraFields contains additional fields you wish to add to the log output. These will overwrite any fields from the original log message. preserveTimestamps will use the timestamps from the original log messages instead of the current time

func WaitForInstance

func WaitForInstance(instance *iscenv.ISCInstance, timeout time.Duration) error

func WaitForInstanceForever

func WaitForInstanceForever(instance *iscenv.ISCInstance, c chan error)

func WaitForPort

func WaitForPort(ip string, port string, timeout time.Duration) error

func WaitForPortForever

func WaitForPortForever(ip string, port string, c chan error)

Types

type DockerConfigError

type DockerConfigError struct {
	ConfigPath string
	Registry   string
	Err        error
}

func NewDockerConfigError

func NewDockerConfigError(path, registry string, err error) *DockerConfigError

func (*DockerConfigError) Error

func (dce *DockerConfigError) Error() string

type DockerExecError

type DockerExecError struct {
	ExitCode int
}

func (DockerExecError) Error

func (dee DockerExecError) Error() string

type DockerStartOptions

type DockerStartOptions struct {
	// The name of the instance
	Name string

	// The full name of the container, if this is populated, it will not be calculated
	// TODO: This is fairly hacky and should be reworked in a future refactoring phase
	FullName string

	// The image repository from which the container will be created
	Repository string

	// The version of the image to use
	Version string

	// The port by which the external ports will be offset (or the starting offset for search if searching)
	PortOffset int64

	// Search for the next available port offset?
	PortOffsetSearch bool

	// Disable the port offset checks, only do this if you are creating additional supplementary containers that use an existing containers offset to offset a different port/set of ports
	// TODO: This is fairly hacky and should be reworked in a future refactoring phase
	DisablePortOffsetConflictCheck bool

	// The entrypoint for the container
	Entrypoint []string

	// The command for the container
	Command []string

	// Environment variables in standard docker format (ENV=VALUE)
	Environment []string

	// Volumes provided in the standard host:container:mode format
	Volumes []string

	// Copies files provided in the format host:container into the container before it starts
	Copies []string

	// The names of containers from which volumes will be used
	VolumesFrom []string

	// Containers to which this container should be linked
	ContainerLinks []string

	// Port mappings in standard <IP>:host:container format
	Ports []string

	// Labels to add to the container
	Labels map[string]string

	// Should the container be deleted if it already exists?
	Recreate bool
}

func (*DockerStartOptions) ContainerName

func (opts *DockerStartOptions) ContainerName() string

func (*DockerStartOptions) InternalVolumes

func (opts *DockerStartOptions) InternalVolumes() map[string]struct{}

func (*DockerStartOptions) ToCreateContainerOptions

func (opts *DockerStartOptions) ToCreateContainerOptions() *docker.CreateContainerOptions

func (*DockerStartOptions) ToDockerPortBindings

func (opts *DockerStartOptions) ToDockerPortBindings() map[docker.Port][]docker.PortBinding

func (*DockerStartOptions) ToExposedPorts

func (opts *DockerStartOptions) ToExposedPorts() map[docker.Port]struct{}

func (*DockerStartOptions) ToHostConfig

func (opts *DockerStartOptions) ToHostConfig() *docker.HostConfig

func (*DockerStartOptions) VolumeBinds

func (opts *DockerStartOptions) VolumeBinds() []string

type ISCInstanceManager

type ISCInstanceManager struct {
	*isclib.Instance
	InstanceRunningHandler  InstanceStateFn
	PrimaryCommand          string
	PrimaryCommandNamespace string
}

Manages a instance within a container

func NewISCInstanceManager

func NewISCInstanceManager(instanceName string, ccontrolPath string, csessionPath string, primaryCommand string, primaryCommandNamespace string) (*ISCInstanceManager, error)

func (*ISCInstanceManager) Manage

func (eim *ISCInstanceManager) Manage() error

type InstanceError

type InstanceError struct {
	InstanceName string
	InstanceID   string
	Err          error
}

func NewInstanceError

func NewInstanceError(name, id string, err error) *InstanceError

func (*InstanceError) Error

func (ie *InstanceError) Error() string

type InstanceStateFn

type InstanceStateFn func(instance *isclib.Instance)

type PluginError

type PluginError struct {
	Plugin       string
	PluginMethod string
	PluginPath   string
	Err          error
}

func NewPluginError

func NewPluginError(plugin, method, path string, err error) *PluginError

func (*PluginError) Error

func (pe *PluginError) Error() string

type StartPhase

type StartPhase uint

type StartStatus

type StartStatus struct {
	Phase           StartPhase       `json:"phase"`
	ActivePlugins   []string         `json:"activePlugins"`
	ExecutingPlugin string           `json:"executingPlugin"`
	InstanceState   *isclib.Instance `json:"instanceState"`
}

func NewStartStatus

func NewStartStatus() *StartStatus

func (*StartStatus) Update

func (ss *StartStatus) Update(phase StartPhase, state *isclib.Instance, executingPlugin string)

type TTYSizeChangeHandler

type TTYSizeChangeHandler func(height, width int)

Jump to

Keyboard shortcuts

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