Documentation ¶
Index ¶
- Constants
- Variables
- func DockerCopy(instance *iscenv.ISCInstance, instancePath, localPath string) error
- func DockerExec(instance *iscenv.ISCInstance, interactive bool, username string, ...) error
- func DockerLogs(instance *iscenv.ISCInstance, since int64, tail string, follow bool, ...) error
- func DockerPort(port iscenv.ContainerPort) docker.Port
- func DockerPortBinding(port int64, portOffset int64) []docker.PortBinding
- func DockerPull(image, tag string) error
- func DockerRemove(instance *iscenv.ISCInstance) error
- func DockerRepoLogger(repo string) *log.Entry
- func DockerStart(opts DockerStartOptions) (id string, err error)
- func EnsureWithinContainer(commandName string) error
- func ErrorLogger(logger log.FieldLogger, err error) *log.Entry
- func FileExists(path string) bool
- func FindInstance(instanceName string) *iscenv.ISCInstance
- func FindInstanceAndLogger(instanceName string) (*iscenv.ISCInstance, *log.Entry)
- func GetContainerForInstance(instance *iscenv.ISCInstance) (*docker.Container, error)
- func GetDocker0InterfaceIP() (string, error)
- func GetDockerBindingPort(bindings []docker.PortBinding) (iscenv.ContainerPort, error)
- func GetInstanceStartTime(instance *iscenv.ISCInstance) (time.Time, error)
- func GetInstances() iscenv.ISCInstances
- func InstanceLogger(instance *iscenv.ISCInstance) *log.Entry
- func InstanceLoggerArgs(instanceName, instanceID string) *log.Entry
- func IsUserRoot() error
- func NewRawTTYStdin() (tty *rawTTYStdin, err error)
- func PluginLogger(id, method, path string) *log.Entry
- func Relog(plog log.FieldLogger, preserveTimestamp bool, rlog map[string]interface{})
- func RelogStream(plog log.FieldLogger, preserveTimestamp bool, r io.Reader)
- func WaitForInstance(instance *iscenv.ISCInstance, timeout time.Duration) error
- func WaitForInstanceForever(instance *iscenv.ISCInstance, c chan error)
- func WaitForPort(ip string, port string, timeout time.Duration) error
- func WaitForPortForever(ip string, port string, c chan error)
- type DockerConfigError
- type DockerExecError
- type DockerStartOptions
- func (opts *DockerStartOptions) ContainerName() string
- func (opts *DockerStartOptions) InternalVolumes() map[string]struct{}
- func (opts *DockerStartOptions) ToCreateContainerOptions() *docker.CreateContainerOptions
- func (opts *DockerStartOptions) ToDockerPortBindings() map[docker.Port][]docker.PortBinding
- func (opts *DockerStartOptions) ToExposedPorts() map[docker.Port]struct{}
- func (opts *DockerStartOptions) ToHostConfig() *docker.HostConfig
- func (opts *DockerStartOptions) VolumeBinds() []string
- type ISCInstanceManager
- type InstanceError
- type InstanceStateFn
- type PluginError
- type StartPhase
- type StartStatus
- type TTYSizeChangeHandler
Constants ¶
const ( StartPhaseStartup = iota StartPhaseInitPlugins StartPhaseInitManager StartPhaseEventBeforeInstance StartPhaseEventWithInstance StartPhaseInstanceRunning StartPhaseEventAfterInstance StartPhaseShutdown )
The order here *must* match the actual order that things are started
Variables ¶
var ( // ErrNoSuchInstance is an error used when the requested instance does not exist ErrNoSuchInstance = errors.New("No such instance") // ErrSingleInstanceArg is an error used when the wrong number of instances is provided ErrSingleInstanceArg = errors.New("Must provide a single instance as the first argument") // ErrFailedToAddPluginFlags is an error used when adding flags for a plugin fails ErrFailedToAddPluginFlags = errors.New("Failed to add flags from plugin") // ErrNotInContainer is an error used when the process is not executed in a container when it should be ErrNotInContainer = errors.New("Not in Docker container") // ErrFailedEventPlugin is an error used when a plugin fails to execute properly ErrFailedEventPlugin = errors.New("Failed to execute event plugin") )
var DockerClient *docker.Client
DockerClient holds a reference to a client for interacting with docker
Functions ¶
func DockerCopy ¶
func DockerCopy(instance *iscenv.ISCInstance, instancePath, localPath string) error
DockerCopy will copy a file from inside an instance to a local path
func DockerExec ¶
func DockerExec(instance *iscenv.ISCInstance, interactive bool, username string, commandAndArgs ...string) error
DockerExec performs a docker exec against the provided instance
func DockerLogs ¶
func DockerLogs(instance *iscenv.ISCInstance, since int64, tail string, follow bool, outputStream io.Writer) error
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
DockerPort creates and returns a container docker port
func DockerPortBinding ¶
DockerPortBinding returns a slice of PortBindings representing the binding between a container port and a host port based on the offset
func DockerPull ¶
DockerPull performs a docker pull of the requested image at the designated tag
func DockerRemove ¶
func DockerRemove(instance *iscenv.ISCInstance) error
DockerRemove removes the container that backs the provided instance
func DockerRepoLogger ¶
DockerRepoLogger creates and returns a logger with a reference to the provided docker repository
func DockerStart ¶
func DockerStart(opts DockerStartOptions) (id string, err error)
DockerStart ensures that a container exists and is started. Returns the ID of the started container or an error
func EnsureWithinContainer ¶
EnsureWithinContainer returns an error if it is executed from outside a container
func ErrorLogger ¶
func ErrorLogger(logger log.FieldLogger, err error) *log.Entry
ErrorLogger will evaluate an error for known error types and return a logger with the appropriate fields pulled from that type of error.
func FileExists ¶
FileExists returns whether the path described by the provided string exists
func FindInstance ¶
func FindInstance(instanceName string) *iscenv.ISCInstance
FindInstance finds and returns the instance with the provided name
func FindInstanceAndLogger ¶
func FindInstanceAndLogger(instanceName string) (*iscenv.ISCInstance, *log.Entry)
FindInstanceAndLogger finds and returns the instance with the provided name and a logger for that instance
func GetContainerForInstance ¶
func GetContainerForInstance(instance *iscenv.ISCInstance) (*docker.Container, error)
GetContainerForInstance finds and returns the container that is backing the provided instance
func GetDocker0InterfaceIP ¶
GetDocker0InterfaceIP finds and returns the ip for the docker0 network interface
func GetDockerBindingPort ¶
func GetDockerBindingPort(bindings []docker.PortBinding) (iscenv.ContainerPort, error)
GetDockerBindingPort returns a DockerPort that represents the first port from the provided bindings Assumes a single binding
func GetInstanceStartTime ¶
func GetInstanceStartTime(instance *iscenv.ISCInstance) (time.Time, error)
GetInstanceStartTime gets and returns the start time of the provided instance
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
InstanceLogger creates and returns a logger for the provided instance
func InstanceLoggerArgs ¶
InstanceLoggerArgs returns an instance logger with the values as args
func NewRawTTYStdin ¶
func NewRawTTYStdin() (tty *rawTTYStdin, err error)
NewRawTTYStdin creates and returns a new raw tty with stdin
func PluginLogger ¶
PluginLogger creates and returns a logger with references to the provided plugin information
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
WaitForInstance will wait for an instance until it is running or the timeout is reached
func WaitForInstanceForever ¶
func WaitForInstanceForever(instance *iscenv.ISCInstance, c chan error)
WaitForInstanceForever ill wait for an instance until it is running
func WaitForPort ¶
WaitForPort waits for a port to become available or until the timeout
func WaitForPortForever ¶
WaitForPortForever waits for a port to become available
Types ¶
type DockerConfigError ¶
DockerConfigError is an used for logging an error with a docker config
func NewDockerConfigError ¶
func NewDockerConfigError(path, registry string, err error) *DockerConfigError
NewDockerConfigError creates and returns a new DockerConfigError
func (*DockerConfigError) Error ¶
func (dce *DockerConfigError) Error() string
Error returns the error string for the error associated with the DockerConfigError
type DockerExecError ¶
type DockerExecError struct {
ExitCode int
}
DockerExecError is used for representing a failed docker exec
func (DockerExecError) Error ¶
func (dee DockerExecError) Error() string
Error will return an error string for a DockerExecError
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 // User to run the container as Username string }
DockerStartOptions holds information used in starting a container
func (*DockerStartOptions) ContainerName ¶
func (opts *DockerStartOptions) ContainerName() string
ContainerName returns the name that should be used for the container that is being managed
func (*DockerStartOptions) InternalVolumes ¶
func (opts *DockerStartOptions) InternalVolumes() map[string]struct{}
InternalVolumes returns a map of the volumes internal to the container extracted from the DockerStartOptions list of volumes
func (*DockerStartOptions) ToCreateContainerOptions ¶
func (opts *DockerStartOptions) ToCreateContainerOptions() *docker.CreateContainerOptions
ToCreateContainerOptions transforms a DockerStartOptions into CreateContainerOptions
func (*DockerStartOptions) ToDockerPortBindings ¶
func (opts *DockerStartOptions) ToDockerPortBindings() map[docker.Port][]docker.PortBinding
ToDockerPortBindings returns a map of Ports to a slice of PortBindings
func (*DockerStartOptions) ToExposedPorts ¶
func (opts *DockerStartOptions) ToExposedPorts() map[docker.Port]struct{}
ToExposedPorts returns a map of ports that are exposed by the contain
func (*DockerStartOptions) ToHostConfig ¶
func (opts *DockerStartOptions) ToHostConfig() *docker.HostConfig
ToHostConfig transforms a DockerStartOptions into a HostConfig
func (*DockerStartOptions) VolumeBinds ¶
func (opts *DockerStartOptions) VolumeBinds() []string
VolumeBinds returns a slice of volumes that should be bound from the DockerStartOptions
type ISCInstanceManager ¶
type ISCInstanceManager struct { *isclib.Instance InstanceRunningHandler InstanceStateFn PrimaryCommand string PrimaryCommandNamespace string }
ISCInstanceManager manages a instance within a container
func NewISCInstanceManager ¶
func NewISCInstanceManager(instanceName string, ccontrolPath string, csessionPath string, primaryCommand string, primaryCommandNamespace string) (*ISCInstanceManager, error)
NewISCInstanceManager creates and returns an ISCInstanceManager
func (*ISCInstanceManager) Manage ¶
func (eim *ISCInstanceManager) Manage() error
Manage starts and manages the lifecycle of the instance associated with the ISCInstanceManager
type InstanceError ¶
InstanceError is an used for logging an error with an instance
func NewInstanceError ¶
func NewInstanceError(name, id string, err error) *InstanceError
NewInstanceError creates and returns a new InstanceError
func (*InstanceError) Error ¶
func (ie *InstanceError) Error() string
Error returns the error string for the error associated with the InstanceError
type InstanceStateFn ¶
type InstanceStateFn func(instance *isclib.Instance)
InstanceStateFn is a type that specifies a function signature for dealing with an instance's state
type PluginError ¶
PluginError is an used for logging an error with a plugin
func NewPluginError ¶
func NewPluginError(plugin, method, path string, err error) *PluginError
NewPluginError creates and returns a new PluginError
func (*PluginError) Error ¶
func (pe *PluginError) Error() string
Error returns the error string for the error associated with the PluginError
type StartStatus ¶
type StartStatus struct { Phase StartPhase `json:"phase"` ActivePlugins []string `json:"activePlugins"` ExecutingPlugin string `json:"executingPlugin"` InstanceState *isclib.Instance `json:"instanceState"` }
StartStatus represents information about the startup of an instance and the current phase it is in
func NewStartStatus ¶
func NewStartStatus() *StartStatus
NewStartStatus creates and returns a new initialized StartStatus
func (*StartStatus) Update ¶
func (ss *StartStatus) Update(phase StartPhase, state *isclib.Instance, executingPlugin string)
Update will update the start phase of the provided instance to the provided start phase
type TTYSizeChangeHandler ¶
type TTYSizeChangeHandler func(height, width int)
TTYSizeChangeHandler is a type that specifies a function signature for dealing with tty size changes
Source Files ¶
- dockerclient.go
- dockerconfigerror.go
- dockercopy.go
- dockerexec.go
- dockerlogs.go
- dockerport.go
- dockerpull.go
- dockerremove.go
- dockerstart.go
- dockerstartoptions.go
- ensurewithincontainer.go
- errors.go
- fileexists.go
- findinstance.go
- getcontainerforinstance.go
- getdocker0interface.go
- getinstances.go
- getinstancestarttime.go
- instanceerror.go
- internalinstancemanager.go
- isuserroot.go
- loghelpers.go
- pluginerror.go
- rawttystdin.go
- relogstream.go
- startstatus.go
- waitforinstance.go
- waitforport.go