runtime

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2018 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
	ErrNotSupported  = errors.New("not supported")
)

Definitions of common error types used throughout runtime implementation. All errors returned by the interface will map into one of these errors classes.

Functions

func ErrWithMessagef

func ErrWithMessagef(err error, format string, args ...interface{}) error

ErrWithMessagef updates error message with formated message I.e. errors.WithMessage(err, fmt.Sprintf(... Hopefully we can change to errors.WithMessagef some day: https://github.com/pkg/errors/pull/118

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is due to a missing resource

Types

type AttachIO

type AttachIO struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

AttachIO provides way to attach stdin,stdout and stderr to container

type Client

type Client interface {
	GetPods(namespace string) ([]model.Pod, error)
	GetPod(namespace, podName string) (model.Pod, error)
	PullImage(namespace, ref string, status *progress.ImageFetch) error
	CreateContainer(pod model.Pod, container model.Container) (model.ContainerStatus, error)
	StartContainer(namespace, id string, io IOSet) (model.ContainerStatus, error)
	StopContainer(namespace, id string) (model.ContainerStatus, error)
	GetNamespaces() ([]string, error)
	IsContainerRunning(namespace, name string) (bool, error)
	GetContainerTaskStatus(namespace, name string) string
	Exec(namespace, podName, execID string, args []string, tty bool, attach AttachIO) error
	Attach(namespace, podName string, attach AttachIO) error
	Signal(namespace, name string, signal syscall.Signal) error
}

Client is interface for underlying container implementation

type ContainerdClient

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

ContainerdClient is containerd client wrapper

func NewContainerdClient

func NewContainerdClient(context context.Context, timeout time.Duration, address, hostname string) *ContainerdClient

NewContainerdClient creates new containerd client with given timeout

func (*ContainerdClient) Attach

func (c *ContainerdClient) Attach(namespace, name string, io AttachIO) error

Attach hook IO to container main process

func (*ContainerdClient) CreateContainer

func (c *ContainerdClient) CreateContainer(pod model.Pod, container model.Container) (status model.ContainerStatus, err error)

CreateContainer creates given container

func (*ContainerdClient) Exec added in v0.2.3

func (c *ContainerdClient) Exec(namespace, name, id string, args []string, tty bool, io AttachIO) error

Exec run command in container and hook IO to the new process

func (*ContainerdClient) GetContainerTaskStatus

func (c *ContainerdClient) GetContainerTaskStatus(namespace, name string) string

GetContainerTaskStatus resolves container status or return UNKNOWN

func (*ContainerdClient) GetNamespaces

func (c *ContainerdClient) GetNamespaces() ([]string, error)

GetNamespaces return all namespaces

func (*ContainerdClient) GetPod

func (c *ContainerdClient) GetPod(namespace, podName string) (model.Pod, error)

GetPod return pod by name

func (*ContainerdClient) GetPods

func (c *ContainerdClient) GetPods(namespace string) ([]model.Pod, error)

GetPods return all containers active in containerd grouped by pods

func (*ContainerdClient) IsContainerRunning

func (c *ContainerdClient) IsContainerRunning(namespace, name string) (bool, error)

IsContainerRunning returns true if container running. If cannot resolve, return false with error

func (*ContainerdClient) PullImage

func (c *ContainerdClient) PullImage(namespace, ref string, progress *progress.ImageFetch) error

PullImage ensures that given container image is pulled to the namespace

func (*ContainerdClient) Signal

func (c *ContainerdClient) Signal(namespace, name string, signal syscall.Signal) error

Signal will send a syscall.Signal to the container task process

func (*ContainerdClient) StartContainer

func (c *ContainerdClient) StartContainer(namespace, id string, ioSet IOSet) (result model.ContainerStatus, err error)

StartContainer starts the pre-created container

func (*ContainerdClient) StopContainer

func (c *ContainerdClient) StopContainer(namespace, name string) (result model.ContainerStatus, err error)

StopContainer stops given container

type IOSet

type IOSet struct {
	Stdin  string
	Stdout string
	Stderr string
}

IOSet represents container process stdin,stdout,stderr files

func NewIOSet

func NewIOSet(id string) (*IOSet, error)

NewIOSet creates new unique IOSet for container

func (*IOSet) PipeStdoutTo

func (s *IOSet) PipeStdoutTo(target *IOSet)

PipeStdoutTo updates the IOSet stdout to another IOSet stdin

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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