Documentation
¶
Index ¶
- Variables
- func AvailableBackends() []core.BackendType
- func NewBackend(config core.BackendConfig) (core.Backend, error)
- func NewFilter(key, value string) filters.Args
- type BuildStatus
- type Client
- type Container
- type ContainerOption
- type DockerImage
- type ImageOption
- type MuxedReadCloser
- type Option
- type PullStatus
Constants ¶
This section is empty.
Variables ¶
var ( ErrorImageOptions = errors.New("image options failed") ErrorImageBuild = errors.New("building image failed") ErrorImagePull = errors.New("pulling image failed") ErrorClientPull = errors.New("client pull failed") ErrorImageBuildDockerFile = errors.New("building Dockerfile failed") ErrorContainerOptions = errors.New("container options failed") ErrorContainerCreate = errors.New("creating container failed") ErrorContainerStart = errors.New("start container failed") ErrorContainerWait = errors.New("container wait failed") ErrorContainerInspect = errors.New("inspecting container failed") ErrorExitCode = errors.New("exit-code") ErrorContainerLogs = errors.New("getting container logs failed") ErrBackendNotAvailable = errors.New("backend not available on this platform") )
var (
ForceRebuild = false
)
Functions ¶
func AvailableBackends ¶ added in v1.1.10
func AvailableBackends() []core.BackendType
AvailableBackends returns all registered backends
func NewBackend ¶ added in v1.1.10
func NewBackend(config core.BackendConfig) (core.Backend, error)
NewBackend creates a backend instance using the registered factory from core
Types ¶
type BuildStatus ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the methods of the docker Client. It now uses a Backend internally for container operations.
func New ¶
New creates a new dockerClient with default Options. Backend is initialized immediately (Docker first, fallback to containerd).
func (*Client) Clean ¶
Clean removes images older than age that match the given filter. Implemented for the Docker backend; other backends return an error.
func (*Client) Close ¶ added in v1.1.10
Close is a no-op for backward compatibility. The backend handles its own lifecycle and doesn't need explicit closing.
func (*Client) Image ¶
func (c *Client) Image(ctx context.Context, name string, options ...ImageOption) (image *DockerImage, err error)
Image initializes the given image. It tries to pull from the registry first to get the latest; if pull fails and the image exists locally, that image is used. If the Build() Option is provided then the given DockerFile tarball is built and returned.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container wraps the methods of the docker container. It now uses a Backend internally for container operations.
func (*Container) Run ¶
func (c *Container) Run(ctx context.Context) (*MuxedReadCloser, error)
Run starts the container and waits for the container to exit before returning the container logs. Logs are returned even when the container exits with a non-zero status so callers can inspect build output (e.g. compiler errors).
type ContainerOption ¶
ContainerOption is a function to set configuration to the Container object.
func Command ¶
func Command(cmd []string) ContainerOption
Command sets the commands to be run by the container after being built.
func Shell ¶
func Shell(cmd []string) ContainerOption
Shell sets the shell-form of RUN, CMD, ENTRYPOINT
func Variable ¶
func Variable(key, value string) ContainerOption
Variable sets an environment variable in the container.
func Variables ¶
func Variables(vars map[string]string) ContainerOption
Variables sets multiple environment variables in the container.
func Volume ¶
func Volume(sourcePath, containerPath string) ContainerOption
Volume sets local directories to be volumed in the container.
func WorkDir ¶
func WorkDir(workDir string) ContainerOption
WorkDir sets the working directory of the container, where calls will be made.
type DockerImage ¶ added in v1.1.10
type DockerImage struct {
// contains filtered or unexported fields
}
DockerImage wraps the methods of the docker image. It now uses a Backend internally for image operations.
func (*DockerImage) Exists ¶ added in v1.1.10
func (i *DockerImage) Exists(ctx context.Context) bool
Exists checks if the image exists locally without pulling
func (*DockerImage) Instantiate ¶ added in v1.1.10
func (i *DockerImage) Instantiate(ctx context.Context, options ...ContainerOption) (*Container, error)
Instantiate sets given options and creates the container from the docker image.
func (*DockerImage) Name ¶ added in v1.1.10
func (i *DockerImage) Name() string
Name returns the name of the image
func (*DockerImage) Pull ¶ added in v1.1.10
func (i *DockerImage) Pull(ctx context.Context, statusChan chan<- PullStatus) (*DockerImage, error)
Pull retrieves latest changes to the image from docker hub.
type ImageOption ¶
type ImageOption func(*DockerImage) error
ImageOption is a function to set configuration to the Image object.
func Build ¶
func Build(tarball io.Reader) ImageOption
Build returns an ImageOption to build a tarball of a Dockerfile
func Dockerfile ¶
func Dockerfile(dockerfile string) ImageOption
func Output ¶
func Output(output io.Writer) ImageOption
type MuxedReadCloser ¶
type MuxedReadCloser struct {
// contains filtered or unexported fields
}
MuxedReadCloser wraps the Read/Close methods for muxed logs.
func (*MuxedReadCloser) Close ¶
func (mx *MuxedReadCloser) Close() error
func (*MuxedReadCloser) Combined ¶
func (mx *MuxedReadCloser) Combined() io.ReadCloser
Combined returns the Stderr, and Stdout combined container logs.
func (*MuxedReadCloser) Separated ¶
func (mx *MuxedReadCloser) Separated() (stdOut io.ReadCloser, stdErr io.ReadCloser)
Separated returns both the standard Out and Error logs of the container.
type PullStatus ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
backends
|
|
|
containerd
Package containerd provides a containerd backend implementation for container operations.
|
Package containerd provides a containerd backend implementation for container operations. |
|
docker
Package docker provides a Docker backend implementation for container operations.
|
Package docker provides a Docker backend implementation for container operations. |
|
Package core provides core interfaces and types for container backends This package is separate from the main containers package to avoid import cycles
|
Package core provides core interfaces and types for container backends This package is separate from the main containers package to avoid import cycles |