runner

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSkip is used as a return value when container execution should be
	// skipped at runtime. It is not returned as an error by any function.
	ErrSkip = errors.New("Skip")

	// ErrTerm is used as a return value when the runner should terminate
	// execution and exit. It is not returned as an error by any function.
	ErrTerm = errors.New("Terminate")
)
View Source
var NoContext = context.TODO()

NoContext is the default context you should supply if not using your own context.Context

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email,omitempty"`
	Token    string `json:"registry_token,omitempty"`
}

Auth provides authentication parameters to authenticate to a remote container registry for image download.

type Config

type Config struct {
	Tracer Tracer
	Engine Engine

	// Buffer defines the size of the buffer for the channel to which the
	// console output is streamed.
	Buffer uint
}

Config defines the configuration for creating the Runner.

func (*Config) Runner

func (c *Config) Runner(ctx context.Context, spec *Spec) *Runner

Runner creates a build Runner using the specific configuration for the given Context and Specification.

type Container

type Container struct {
	Name           string            `json:"name"`
	Alias          string            `json:"alias"`
	Image          string            `json:"image"`
	Pull           bool              `json:"pull,omitempty"`
	AuthConfig     Auth              `json:"auth_config,omitempty"`
	Privileged     bool              `json:"privileged,omitempty"`
	WorkingDir     string            `json:"working_dir,omitempty"`
	Environment    map[string]string `json:"environment,omitempty"`
	Entrypoint     []string          `json:"entrypoint,omitempty"`
	Command        []string          `json:"command,omitempty"`
	ExtraHosts     []string          `json:"extra_hosts,omitempty"`
	Volumes        []string          `json:"volumes,omitempty"`
	VolumesFrom    []string          `json:"volumes_from,omitempty"`
	Devices        []string          `json:"devices,omitempty"`
	Network        string            `json:"network_mode,omitempty"`
	DNS            []string          `json:"dns,omitempty"`
	DNSSearch      []string          `json:"dns_search,omitempty"`
	MemSwapLimit   int64             `json:"memswap_limit,omitempty"`
	MemLimit       int64             `json:"mem_limit,omitempty"`
	CPUQuota       int64             `json:"cpu_quota,omitempty"`
	CPUShares      int64             `json:"cpu_shares,omitempty"`
	CPUSet         string            `json:"cpuset,omitempty"`
	OomKillDisable bool              `json:"oom_kill_disable,omitempty"`
}

Container defines the container configuration.

func (*Container) Validate

func (c *Container) Validate() error

Validate validates the container configuration details and returns an error if the validation fails.

type Engine

type Engine interface {
	// VolumeCreate(*Volume) (string, error)
	// VolumeRemove(string) error
	ContainerStart(*Container) (string, error)
	ContainerStop(string) error
	ContainerRemove(string) error
	ContainerWait(string) (*State, error)
	ContainerLogs(string) (io.ReadCloser, error)
}

Engine defines the container runtime engine.

type ExitError

type ExitError struct {
	Name string
	Code int
}

An ExitError reports an unsuccessful exit.

func (*ExitError) Error

func (e *ExitError) Error() string

Error reteurns the error message in string format.

type Line

type Line struct {
	Proc string `json:"proc,omitempty"`
	Time int64  `json:"time,omitempty"`
	Type int    `json:"type,omitempty"`
	Pos  int    `json:"pos,omityempty"`
	Out  string `json:"out,omitempty"`
}

Line is a line of console output.

func (*Line) String

func (l *Line) String() string

type Network

type Network struct {
	Name       string            `json:"name,omitempty"`
	Alias      string            `json:"alias,omitempty"`
	Driver     string            `json:"driver,omitempty"`
	DriverOpts map[string]string `json:"driver_opts,omitempty"`
	External   bool              `json:"external,omitempty"`
}

Network defines a container network.

type OomError

type OomError struct {
	Name string
}

An OomError reports the process received an OOMKill from the kernel.

func (*OomError) Error

func (e *OomError) Error() string

Error reteurns the error message in string format.

type Pipe

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

Pipe returns a buffered pipe that is connected to the console output.

func (*Pipe) Close

func (p *Pipe) Close()

Close closes the pipe of console output.

func (*Pipe) Next

func (p *Pipe) Next() *Line

Next returns the next Line of console output.

type Runner

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

func (*Runner) Pipe

func (r *Runner) Pipe() *Pipe

Pipe returns a Pipe that is connected to the console output stream.

func (*Runner) Run

func (r *Runner) Run()

Run starts the build runner but does not wait for it to complete. The Wait method will return the exit code and release associated resources once the running containers exit.

func (*Runner) Wait

func (r *Runner) Wait() error

Wait waits for the runner to exit.

type Spec

type Spec struct {
	// Volumes defines a list of all container volumes.
	Volumes []*Volume `json:"volumes,omitempty"`

	// Networks defines a list of all container networks.
	Networks []*Network `json:"networks,omitempty"`

	// Containers defines a list of all containers in the pipeline.
	Containers []*Container `json:"containers,omitempty"`

	// Nodes defines the container execution tree.
	Nodes *parse.Tree `json:"program,omitempty"`
}

Spec defines the pipeline configuration and exeuction.

func Parse

func Parse(data []byte) (*Spec, error)

Parse parses a raw file containing a JSON encoded format of an intermediate representation of the pipeline.

func ParseFile

func ParseFile(filename string) (*Spec, error)

ParseFile parses a file containing a JSON encoded format of an intermediate representation of the pipeline.

type State

type State struct {
	ExitCode  int  // container exit code
	OOMKilled bool // container exited due to oom error
}

State defines the state of the container.

type Tracer

type Tracer func(c *Container) error

Tracer defines a tracing function that is invoked prior to creating and running the container.

type Volume

type Volume struct {
	Name       string            `json:"name,omitempty"`
	Alias      string            `json:"alias,omitempty"`
	Driver     string            `json:"driver,omitempty"`
	DriverOpts map[string]string `json:"driver_opts,omitempty"`
	External   bool              `json:"external,omitempty"`
}

Volume defines a container volume.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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