driver

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package driver hold implementation for container runtimes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 ContainerDefinition added in v0.21.0

type ContainerDefinition struct {
	Hostname      string
	ContainerName string
	Image         string

	Entrypoint []string
	Command    []string
	WorkingDir string

	// @todo review binds and volumes, because binds won't work for remote environments.
	Binds   []string
	Volumes []ContainerVolume

	Streams ContainerStreamsOptions

	Env        []string
	User       string
	ExtraHosts []string
}

ContainerDefinition 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
	Err io.Reader

	Opts       ContainerStreamsOptions
	TtyMonitor *TtySizeMonitor
}

ContainerInOut stores container in/out streams.

func (*ContainerInOut) Close

func (cio *ContainerInOut) Close() error

Close closes the IO and underlying connection.

func (*ContainerInOut) Stream added in v0.21.0

func (cio *ContainerInOut) Stream(ctx context.Context, streams launchr.Streams) error

Stream streams in/out/err to given streams.

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 struct {
	Name       string
	Size       int64
	Mode       os.FileMode
	Mtime      time.Time
	LinkTarget string
}

ContainerPathStat is a type alias for container path stat result.

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 ContainerDefinition) (string, error)
	ContainerStart(ctx context.Context, cid string, opts ContainerDefinition) (<-chan int, *ContainerInOut, error)
	ContainerStop(ctx context.Context, cid string, opts ContainerStopOptions) error
	ContainerKill(ctx context.Context, cid, signal string) error
	ContainerRemove(ctx context.Context, cid string) error
	Close() error
}

ContainerRunner defines common interface for container environments.

func New

func New(t Type) (ContainerRunner, error)

New creates a new container runtime based on a type.

func NewDockerRuntime added in v0.21.0

func NewDockerRuntime() (ContainerRunner, error)

NewDockerRuntime creates a docker runtime.

func NewKubernetesRuntime added in v0.21.0

func NewKubernetesRuntime() (ContainerRunner, error)

NewKubernetesRuntime creates a kubernetes container runtime.

type ContainerRunnerSELinux added in v0.16.0

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

ContainerRunnerSELinux defines a container runner with SELinux support.

type ContainerStopOptions

type ContainerStopOptions struct {
	Timeout *time.Duration
}

ContainerStopOptions stores options to stop a container.

type ContainerStreamsOptions added in v0.21.0

type ContainerStreamsOptions struct {
	TTY    bool
	Stdin  bool
	Stdout bool
	Stderr bool
}

ContainerStreamsOptions stores options for attaching to streams of a running container.

type ContainerVolume added in v0.21.0

type ContainerVolume struct {
	// Name is a volume name. Leave empty for an anonymous volume.
	Name string
	// MountPath is a path within the container at which the volume should be mounted. Must not contain ':'.
	MountPath string
}

ContainerVolume stores volume definition for a container.

type CopyToContainerOptions added in v0.18.0

type CopyToContainerOptions struct {
	AllowOverwriteDirWithFile bool
	CopyUIDGID                bool
}

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

type ImageOptions

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

ImageOptions stores options for creating/pulling an image.

type ImageProgressStream added in v0.21.0

type ImageProgressStream struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

ImageProgressStream holds Image progress reader and a way to stream it to the given output.

func (*ImageProgressStream) Close added in v0.21.0

func (p *ImageProgressStream) Close() error

Close closes the reader.

func (*ImageProgressStream) Stream added in v0.21.0

func (p *ImageProgressStream) Stream(out *launchr.Out) error

Stream outputs progress to the given output.

type ImageRemoveOptions added in v0.18.0

type ImageRemoveOptions struct {
	Force bool
}

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 *ImageProgressStream
}

ImageStatusResponse stores the response when getting the image.

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
	Remote          bool // Remote defines if local or remote containers are spawned.
}

SystemInfo holds information about the container runner environment.

type TtySizeMonitor added in v0.21.0

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

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

func NewTtySizeMonitor added in v0.21.0

func NewTtySizeMonitor(resizeFn resizeTtyFn) *TtySizeMonitor

NewTtySizeMonitor creates a new TtySizeMonitor.

func (*TtySizeMonitor) Start added in v0.21.0

func (t *TtySizeMonitor) Start(ctx context.Context, streams launchr.Streams)

Start starts tty size watching.

type Type

type Type string

Type defines implemented container runtime types.

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

Available container runtime types.

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