exec2

package
v1.5.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicHandleFactory

type BasicHandleFactory struct {
}

type Config

type Config struct {
	Name   string
	Limits ResourceLimits
}

variable container configuration state

type ConstantConfig

type ConstantConfig struct {
	ContainerID ID
	Created     time.Time
}

config state that cannot change for the lifetime of the container

type ContainerConfig

type ContainerConfig struct {
	ConstantConfig
	Config
	MainProcess ProcessConfig
	ExecdProcs  []ProcessConfig
}

ContainerConfig is a type representing the configuration of a container and its processes

type ContainerLifecycle

type ContainerLifecycle interface {

	// CreateContainer creates a new container representation and returns a Handle
	// The Handle can be used to configure the container before its actually created
	// Calling Commit on the Handle will create the container
	CreateContainer(name string) (Handle, error)

	// GetHandle allows for an existing container to be modified
	// The Handle can be used to reconfigure the container
	// Calling Commit on the Handle will apply the reconfiguration
	// Commit will fail if another client committed a modification after GetHandle was called
	GetHandle(cid ID) (Handle, error)

	// CopyTo copies a file into the container represented by the handle
	// If the container is stopped, the file will be copied in when it is next started
	CopyTo(handle Handle, targetDir string, fname string, perms int16, data []byte) (Handle, error)

	// SetEntryPoint sets the entry point for the container
	// This is the executable, the lifecycle of which is tied to the container lifecycle
	SetEntryPoint(handle Handle, workDir string, execPath string, execArgs string) (Handle, error)

	// SetLimits sets resource limits on the container
	// A value of -1 implies a default value, not unlimited
	// New limits will be ignored if committed to a running container
	SetLimits(handle Handle, memoryMb int, cpuMhz int) (Handle, error)

	// SetRunState allows for the running state of a container to be modified
	// Created is not a valid state and will return an error
	SetRunState(handle Handle, runState RunState) (Handle, error)

	// Commit applies changes made to the Handle to either a new or running container
	// Commit will fail if another client committed a modification after GetHandle was called
	// Commit blocks until all changes have been committed
	Commit(handle Handle) (ID, error)

	// DestroyContainer destroys an stopped container
	// It is up to the caller to put the container in stopped state before calling Destroy
	DestroyContainer(cid ID) error
}

ContainerLifecycle represents operations concerned with the creation, modification and deletion of containers

type ContainerQuery

type ContainerQuery interface {

	// ListContainers lists all container IDs for a given state
	// If forState is nil, all containers are returned
	ListContainers(forState RunState) ([]ID, error)

	// GetConfig returns container and process config
	GetContainerConfig(cid ID) (ContainerConfig, error)

	// GetState returns the current state of the container and its processes
	// This call will return a snapshot of the most recent state for each entity
	GetContainerState(cid ID) (ContainerState, error)

	// CopyFrom copies file data out of a running container
	// Returns an error if the container is not running
	CopyFrom(cid ID, sourceDir string, fname string) ([]byte, error)
}

ContainerQuery represents queries that can be made against a Container

type ContainerState

type ContainerState struct {
	Status      RunState
	MainProcess ProcessState
	ExecdProcs  []ProcessState
}

ContainerState is a type representing the runtime state of a container and its processes

type FileToCopy

type FileToCopy struct {
	// contains filtered or unexported fields
}

type Handle

type Handle interface{}

A Handle should be completely opaque

type HandleFactory

type HandleFactory interface {
	// contains filtered or unexported methods
}

type ID

type ID uuid.UUID

func GenerateID

func GenerateID() ID

func ParseID

func ParseID(idStr string) (ID, error)

func (ID) String

func (id ID) String() string

type PendingCommit

type PendingCommit struct {
	ConstantConfig
	// contains filtered or unexported fields
}

config that will be applied to a container on commit Needs to be public as it will be shared by net, storage etc

type PortLayerVsphere

type PortLayerVsphere struct {
	// contains filtered or unexported fields
}

PortLayerVsphere is a WIP implementation of the execution.go interfaces

func (*PortLayerVsphere) Commit

func (p *PortLayerVsphere) Commit(handle Handle) (ID, error)

func (*PortLayerVsphere) CopyTo

func (p *PortLayerVsphere) CopyTo(handle Handle, targetDir string, fname string, perms int16, data []byte) (Handle, error)

func (*PortLayerVsphere) CreateContainer

func (p *PortLayerVsphere) CreateContainer(name string) (Handle, error)

func (*PortLayerVsphere) DestroyContainer

func (p *PortLayerVsphere) DestroyContainer(cid ID) error

func (*PortLayerVsphere) GetHandle

func (p *PortLayerVsphere) GetHandle(cid ID) (Handle, error)

func (*PortLayerVsphere) Init

func (p *PortLayerVsphere) Init(gateway VmomiGateway, factory HandleFactory) error

func (*PortLayerVsphere) SetEntryPoint

func (p *PortLayerVsphere) SetEntryPoint(handle Handle, workDir string, execPath string, execArgs string) (Handle, error)

func (*PortLayerVsphere) SetLimits

func (p *PortLayerVsphere) SetLimits(handle Handle, memoryMb int, cpuMhz int) (Handle, error)

func (*PortLayerVsphere) SetRunState

func (p *PortLayerVsphere) SetRunState(handle Handle, runState RunState) (Handle, error)

type ProcessConfig

type ProcessConfig struct {
	ProcessID ID
	WorkDir   string
	ExecPath  string
	ExecArgs  string
}

configuration state of a container process

func NewProcessConfig

func NewProcessConfig(workDir string, execPath string, execArgs string) ProcessConfig

type ProcessLifecycle

type ProcessLifecycle interface {
	// ExecProcess executes a process in the container
	// The lifecycle of the process is independent of the container main process
	// The ID returned is a uuid handle to the process
	ExecProcess(cid ID, workDir string, execPath string, execArgs string) (ID, error)

	// Send a signal to the process
	// Specifying a process ID will signal an exec'd process. Specifying the container ID will signal the main process
	Signal(processID ID, signal int) error
}

type ProcessRunState

type ProcessRunState struct {
	ProcessID  ID
	Status     ProcessStatus
	GuestPid   int
	ExitCode   int
	ExitMsg    string
	StartedAt  time.Time
	FinishedAt time.Time
}

runtime status of a container process

type ProcessState

type ProcessState struct {
	ProcessRunState
}

ProcessState is the runtime state of a process in a container

type ProcessStatus

type ProcessStatus int
const (
	Started ProcessStatus
	Exited
)

type ResourceLimits

type ResourceLimits struct {
	MemoryMb int
	CPUMhz   int
}

type RunState

type RunState int

RunState represents the running state of a container

const (
	Created RunState
	Running
	Stopped
)

type VmomiGateway

type VmomiGateway interface {
}

VmomiGateway represents an interface to a pre-authenticated Vmomi API

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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