container

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 34 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDockerCLIOptions

func DefaultDockerCLIOptions() []command.DockerCliOption

DefaultDockerCLIOptions returns default docker cli options which attach cli streams to stdio

Types

type Container

type Container interface {
	ParseURL(url string) (reference.NamedTagged, error)
	RepoInfo(ref reference.NamedTagged) (*registry.RepositoryInfo, error)
	Auth(ctx context.Context, ref reference.NamedTagged, cmdName string) (string, types.RequestPrivilegeFunc, error)
	PullImage(ctx context.Context, imageURL string) error
	PushImage(ctx context.Context, imageURL string) error
	RepoGetTags(ctx context.Context, imageURL string) ([]string, error)
	RepoImageExists(ctx context.Context, imageURL string) (bool, error)
	ImageList(ctx context.Context) ([]types.ImageSummary, error)
	ImageExists(ctx context.Context, imageURL string) (bool, error)
	Start(eg *errgroup.Group, ctx context.Context, opts StartOptions) (string, func(), error)
	Wait(ctx context.Context, containerID string, condition WaitCondition) error
	Logs(ctx context.Context, containerID string) (io.ReadCloser, error)
	StreamLogs(stdout, stderr io.Writer, logs io.Reader) error
}

Container a generic interface representing container system interactions

type Docker

type Docker struct {
	OutputWriter io.Writer
	// contains filtered or unexported fields
}

Docker an implementation of the container interface

func NewDockerClient

func NewDockerClient(cliOptions ...command.DockerCliOption) (*Docker, error)

NewDockerClient returns an instance of the Docker container interface

func (*Docker) Auth

Auth returns credentials for operations that require authentication

func (*Docker) Build

func (d *Docker) Build(eg *errgroup.Group, ctx context.Context, dockerContext io.Reader, opts types.ImageBuildOptions) error

Build starts a docker build

func (*Docker) ImageExists

func (d *Docker) ImageExists(ctx context.Context, imageURL string) (bool, error)

ImageExists returns true if an image exists locally

func (*Docker) ImageList

func (d *Docker) ImageList(ctx context.Context) ([]types.ImageSummary, error)

ImageList returns the local list of images

func (*Docker) Logs

func (d *Docker) Logs(ctx context.Context, containerID string) (io.ReadCloser, error)

Logs a log stream for the given containerID

func (*Docker) ParseURL

func (d *Docker) ParseURL(url string) (reference.NamedTagged, error)

ParseURL returns a docker repository reference from a given url string

func (*Docker) PullImage

func (d *Docker) PullImage(ctx context.Context, imageURL string) error

PullImage pulls a docker image from the given url

func (*Docker) PushImage

func (d *Docker) PushImage(ctx context.Context, imageURL string) error

PushImage pushes a docker image to the given url

func (*Docker) RepoGetTags

func (d *Docker) RepoGetTags(ctx context.Context, imageURL string) ([]string, error)

RepoGetTags searches a remote repository and lists all tags for that image

func (*Docker) RepoImageExists

func (d *Docker) RepoImageExists(ctx context.Context, imageURL string) (bool, error)

RepoImageExists searches for the existence of an image in a remote repo

func (*Docker) RepoInfo

RepoInfo returns the repository information for a given image reference

func (*Docker) Start

func (d *Docker) Start(eg *errgroup.Group, ctx context.Context, opts StartOptions) (containerID string, finish func(), err error)

Start starts a docker container using the given image reference. The finish callback must be executed for this function's error group to complete, exiting the run

Example:

containerID, finish, err := docker.Start()
defer finish()

func (*Docker) StartBuildkitSession

func (d *Docker) StartBuildkitSession(eg *errgroup.Group, ctx context.Context, secretSpecs []secretsprovider.FileSource, key string) (*session.Session, error)

StartBuildkitSession func (d *Docker) StartBuildkitSession(ctx context.Context, key string, sshSpecs []string, secretSpecs []string) (*session.Session, error) {

func (*Docker) StreamLogs

func (d *Docker) StreamLogs(stdout, stderr io.Writer, logs io.Reader) error

StreamLogs streams logs to the given destinations

func (*Docker) Wait

func (d *Docker) Wait(ctx context.Context, containerID string, condition WaitCondition) error

Wait for a container condition to change

type StartOptions

type StartOptions struct {
	AutoRemove    bool
	AttachStdIn   bool
	Privileged    bool
	Image         string
	WorkingDir    string
	ContainerName string
	Binds         []string
	Cmd           []string
	Env           map[string]string
	PortBindings  nat.PortMap
	ExposedPorts  nat.PortSet
	KillTimeout   time.Duration
	InputStream   io.Reader
	OutputStream  io.Writer
	NetworkMode   string
}

StartOptions options for the container.Start method

type WaitCondition

type WaitCondition string

WaitCondition provides specificity to the type of string recognized as a container wait condition

const (
	// WaitConditionNotRunning defines the 'not-running' condition to check while waiting
	WaitConditionNotRunning WaitCondition = "not-running"
)

Jump to

Keyboard shortcuts

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