driver

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package driver hold implementation for container runtimes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerIOStream

func ContainerIOStream(ctx context.Context, streams launchr.Streams, cio *ContainerInOut, config *ContainerCreateOptions) error

ContainerIOStream streams in/out/err to given streams. @todo consider license reference.

func DockerDisplayJSONMessages added in v0.17.1

func DockerDisplayJSONMessages(in io.Reader, streams launchr.Streams) error

DockerDisplayJSONMessages prints docker json output to streams.

func ForwardAllSignals added in v0.17.1

func ForwardAllSignals(ctx context.Context, cli ContainerRunner, cid string, sigc <-chan os.Signal)

ForwardAllSignals forwards signals to the container

The channel you pass in must already be setup to receive any signals you want to forward.

func GetRandomName added in v0.17.1

func GetRandomName(retry int) string

GetRandomName generates a random human-friendly name.

func MonitorTtySize

func MonitorTtySize(ctx context.Context, d ContainerRunner, cli launchr.Streams, id string, isExec bool) error

MonitorTtySize updates the container tty size when the terminal tty changes size

func NotifyAllSignals added in v0.17.1

func NotifyAllSignals() chan os.Signal

NotifyAllSignals starts watching interrupt signals.

func StopCatchSignals added in v0.17.1

func StopCatchSignals(sigc chan os.Signal)

StopCatchSignals stops catching the signals and closes the specified channel.

Types

type BuildDefinition added in v0.18.0

type BuildDefinition struct {
	Context   string             `yaml:"context"`
	Buildfile string             `yaml:"buildfile"`
	Args      map[string]*string `yaml:"args"`
	Tags      []string           `yaml:"tags"`
}

BuildDefinition stores image build definition.

func (*BuildDefinition) ImageBuildInfo added in v0.18.0

func (b *BuildDefinition) ImageBuildInfo(name string, cwd string) *BuildDefinition

ImageBuildInfo preprocesses build info to be ready for a container build.

func (*BuildDefinition) UnmarshalYAML added in v0.18.0

func (b *BuildDefinition) UnmarshalYAML(n *yaml.Node) (err error)

UnmarshalYAML implements yaml.Unmarshaler to parse build options from a string or a struct.

type ContainerAttachOptions

type ContainerAttachOptions = typescontainer.AttachOptions

ContainerAttachOptions stores options for attaching to a running container.

type ContainerCreateOptions

type ContainerCreateOptions struct {
	Hostname      string
	ContainerName string
	Image         string
	Cmd           []string
	WorkingDir    string
	Binds         []string
	Volumes       map[string]struct{}
	NetworkMode   NetworkMode
	ExtraHosts    []string
	AutoRemove    bool
	OpenStdin     bool
	StdinOnce     bool
	AttachStdin   bool
	AttachStdout  bool
	AttachStderr  bool
	Tty           bool
	Env           []string
	User          string
	Entrypoint    []string
}

ContainerCreateOptions stores options for creating a new container.

type ContainerImageBuilder added in v0.18.0

type ContainerImageBuilder interface {
	ContainerRunner
	ImageEnsure(ctx context.Context, opts ImageOptions) (*ImageStatusResponse, error)
	ImageRemove(ctx context.Context, image string, opts ImageRemoveOptions) (*ImageRemoveResponse, error)
}

ContainerImageBuilder is an interface for container runtime to build images.

type ContainerInOut

type ContainerInOut struct {
	In  io.WriteCloser
	Out io.Reader
}

ContainerInOut stores container driver in/out streams.

func (*ContainerInOut) Close

func (h *ContainerInOut) Close() error

Close closes the hijacked connection and reader.

func (*ContainerInOut) CloseWrite

func (h *ContainerInOut) CloseWrite() error

CloseWrite closes a readWriter for writing.

type ContainerListOptions

type ContainerListOptions struct {
	SearchName string
}

ContainerListOptions stores options to request container list.

type ContainerListResult

type ContainerListResult struct {
	ID     string
	Names  []string
	Status string
}

ContainerListResult defines container list result.

type ContainerPathStat added in v0.18.0

type ContainerPathStat = typescontainer.PathStat

ContainerPathStat is a type alias for container path stat result.

type ContainerRemoveOptions

type ContainerRemoveOptions = typescontainer.RemoveOptions

ContainerRemoveOptions stores options to remove a container.

type ContainerRunner

type ContainerRunner interface {
	Info(ctx context.Context) (SystemInfo, error)
	CopyToContainer(ctx context.Context, cid string, path string, content io.Reader, opts CopyToContainerOptions) error
	CopyFromContainer(ctx context.Context, cid, srcPath string) (io.ReadCloser, ContainerPathStat, error)
	ContainerStatPath(ctx context.Context, cid string, path string) (ContainerPathStat, error)
	ContainerList(ctx context.Context, opts ContainerListOptions) []ContainerListResult
	ContainerCreate(ctx context.Context, opts ContainerCreateOptions) (string, error)
	ContainerStart(ctx context.Context, cid string, opts ContainerStartOptions) error
	ContainerWait(ctx context.Context, cid string, opts ContainerWaitOptions) (<-chan ContainerWaitResponse, <-chan error)
	ContainerAttach(ctx context.Context, cid string, opts ContainerAttachOptions) (*ContainerInOut, error)
	ContainerStop(ctx context.Context, cid string) error
	ContainerKill(ctx context.Context, cid, signal string) error
	ContainerRemove(ctx context.Context, cid string, opts ContainerRemoveOptions) error
	ContainerResize(ctx context.Context, cid string, opts ResizeOptions) error
	ContainerExecResize(ctx context.Context, cid string, opts ResizeOptions) error
	Close() error
}

ContainerRunner defines common interface for container environments.

func New

func New(t Type) (ContainerRunner, error)

New creates a new driver based on a type.

func NewDockerDriver

func NewDockerDriver() (ContainerRunner, error)

NewDockerDriver creates a docker driver.

type ContainerRunnerSELinux added in v0.16.0

type ContainerRunnerSELinux interface {
	IsSELinuxSupported(ctx context.Context) bool
}

ContainerRunnerSELinux defines a container runner with SELinux support.

type ContainerStartOptions

type ContainerStartOptions struct {
}

ContainerStartOptions stores options for starting a container.

type ContainerStopOptions

type ContainerStopOptions struct {
	Timeout *time.Duration
}

ContainerStopOptions stores options to stop a container.

type ContainerWaitOptions

type ContainerWaitOptions struct {
	Condition WaitCondition
}

ContainerWaitOptions stores options for waiting while container works.

type ContainerWaitResponse

type ContainerWaitResponse struct {
	StatusCode int
	Error      error
}

ContainerWaitResponse stores response given by wait result.

type CopyToContainerOptions added in v0.18.0

type CopyToContainerOptions = typescontainer.CopyToContainerOptions

CopyToContainerOptions is a type alias for container copy to container options.

type EscapeError added in v0.17.1

type EscapeError = term.EscapeError

EscapeError is an error thrown when escape sequence is input.

type ImageOptions

type ImageOptions struct {
	Name         string
	Build        *BuildDefinition
	NoCache      bool
	ForceRebuild bool
}

ImageOptions stores options for creating/pulling an image.

type ImageRemoveOptions added in v0.18.0

type ImageRemoveOptions = typesimage.RemoveOptions

ImageRemoveOptions stores options for removing an image.

type ImageRemoveResponse added in v0.18.0

type ImageRemoveResponse struct {
	Status ImageStatus
}

ImageRemoveResponse stores response when removing the image.

type ImageStatus

type ImageStatus int64

ImageStatus defines image status on local machine.

const (
	ImageExists          ImageStatus = iota // ImageExists - image exists locally.
	ImageUnexpectedError                    // ImageUnexpectedError - image can't be pulled or retrieved.
	ImagePull                               // ImagePull - image is being pulled from the registry.
	ImageBuild                              // ImageBuild - image is being built.
	ImageRemoved                            // ImageRemoved - image was removed
)

Image statuses.

type ImageStatusResponse

type ImageStatusResponse struct {
	Status   ImageStatus
	Progress io.ReadCloser
}

ImageStatusResponse stores response when getting the image.

type NetworkMode added in v0.18.0

type NetworkMode = typescontainer.NetworkMode

NetworkMode is a type alias for container Network mode.

const (
	NetworkModeHost NetworkMode = "host" // NetworkModeHost for host network.
)

Network modes.

type ResizeOptions

type ResizeOptions = typescontainer.ResizeOptions

ResizeOptions is a struct for terminal resizing.

type Streamer

type Streamer interface {
	Stream(ctx context.Context) error
	Close() error
}

Streamer is an interface for streaming in given in/out/err.

type SystemInfo added in v0.18.0

type SystemInfo struct {
	ID              string
	Name            string
	ServerVersion   string
	KernelVersion   string
	OperatingSystem string
	OSVersion       string
	OSType          string
	Architecture    string
	NCPU            int
	MemTotal        int64
	SecurityOptions []string
}

SystemInfo holds information about the container runner environment.

type Type

type Type string

Type defines implemented driver types.

const (
	Docker     Type = "docker"     // Docker runtime.
	Kubernetes Type = "kubernetes" // Kubernetes runtime.
)

Available container runtime types.

type WaitCondition

type WaitCondition = typescontainer.WaitCondition

WaitCondition is a type for available wait conditions.

const (
	WaitConditionNotRunning WaitCondition = typescontainer.WaitConditionNotRunning // WaitConditionNotRunning when container exits when running.
	WaitConditionNextExit   WaitCondition = typescontainer.WaitConditionNextExit   // WaitConditionNextExit when container exits after next start.
	WaitConditionRemoved    WaitCondition = typescontainer.WaitConditionRemoved    // WaitConditionRemoved when container is removed.
)

Container wait conditions.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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