driver

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package driver hold implementation for action drivers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerIOStream

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

ContainerIOStream streams in/out/err to given streams.

func MonitorTtySize

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

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

Types

type ContainerAttachOptions

type ContainerAttachOptions struct {
	AttachStdin  bool
	AttachStdout bool
	AttachStderr bool
	Tty          bool
}

ContainerAttachOptions stores options for attaching to a running container.

type ContainerCreateOptions

type ContainerCreateOptions struct {
	ContainerName string
	Image         string
	Cmd           []string
	WorkingDir    string
	Mounts        map[string]string
	ExtraHosts    []string
	AutoRemove    bool
	OpenStdin     bool
	StdinOnce     bool
	AttachStdin   bool
	AttachStdout  bool
	AttachStderr  bool
	Tty           bool
	Env           []string
}

ContainerCreateOptions stores options for creating a new container.

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 ContainerRemoveOptions

type ContainerRemoveOptions struct {
}

ContainerRemoveOptions stores options to remove a container.

type ContainerRunner

type ContainerRunner interface {
	ImageEnsure(ctx context.Context, opts ImageOptions) (*ImageStatusResponse, 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 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 ImageOptions

type ImageOptions struct {
	Name  string
	Build *cli.BuildDefinition
}

ImageOptions stores options for creating/pulling an 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.
)

type ImageStatusResponse

type ImageStatusResponse struct {
	Status   ImageStatus
	Progress io.ReadCloser
}

ImageStatusResponse stores response when getting the image.

type ResizeOptions

type ResizeOptions struct {
	Height uint
	Width  uint
}

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 Type

type Type string

Type defines implemented driver types.

const (
	Docker Type = "docker" // Docker driver
)

type WaitCondition

type WaitCondition string

WaitCondition is a type for available wait conditions.

const (
	WaitConditionNotRunning WaitCondition = "not-running" // WaitConditionNotRunning when container exits when running.
	WaitConditionNextExit   WaitCondition = "next-exit"   // WaitConditionNextExit when container exits after next start.
	WaitConditionRemoved    WaitCondition = "removed"     // WaitConditionRemoved when container is removed.
)

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