Documentation
¶
Index ¶
- Variables
- func AvailableBackends() []core.BackendType
- func NewBackend(config core.BackendConfig) (core.Backend, error)
- type BuildStatus
- type Client
- func (c *Client) Clean(ctx context.Context, age time.Duration, reference string) error
- func (c *Client) CleanUnused(ctx context.Context, idle time.Duration, keep ...string) error
- func (c *Client) Close() error
- func (c *Client) Image(ctx context.Context, name string, options ...ImageOption) (image *DockerImage, err error)
- type Container
- type ContainerOption
- func Command(cmd []string) ContainerOption
- func NamedVolume(name, containerPath string) ContainerOption
- func Resources(limits core.ResourceLimits) ContainerOption
- func RestrictedEgress() ContainerOption
- func Variable(key, value string) ContainerOption
- func Variables(vars map[string]string) ContainerOption
- func Volume(sourcePath, containerPath string) ContainerOption
- func WorkDir(workDir string) 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") ErrorOutOfMemory = errors.New("out of memory") ErrorKilled = errors.New("killed") 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) CleanUnused ¶ added in v1.3.0
CleanUnused removes the images this process has used but not for idle or longer, except those named in keep. Images it never used are left alone: they are not tau's to remove. An image a container still holds fails to remove and is tried again later.
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, a local copy is used only if this process pulled it before (or TrustLocal is set). If the Build() Option is provided then the given DockerFile tarball is built, once, 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); that status comes back as an error wrapping ErrorExitCode.
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 NamedVolume ¶ added in v1.3.0
func NamedVolume(name, containerPath string) ContainerOption
NamedVolume mounts the backend-managed volume name at containerPath, so its contents outlive the container.
func Resources ¶ added in v1.3.0
func Resources(limits core.ResourceLimits) ContainerOption
Resources caps the container's memory, CPU and processes.
func RestrictedEgress ¶ added in v1.2.0
func RestrictedEgress() ContainerOption
RestrictedEgress makes the backend confine the container's network egress to the public internet — blocking node-local services, the cloud metadata endpoint, and private/link-local ranges. Set for any workload the node did not author — a build running a repository's own build.sh, a tenant's container. Enforcement is fail-closed: if the firewall cannot be installed the container is not started.
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
func RestrictedBuildEgress ¶ added in v1.2.0
func RestrictedBuildEgress() ImageOption
RestrictedBuildEgress confines a Dockerfile build's egress, the way RestrictedEgress does for a container it is the image of.
func ReusePulled ¶ added in v1.3.0
func ReusePulled(age time.Duration) ImageOption
ReusePulled uses a local copy this process pulled less than age ago as is, instead of asking the registry for a newer one every time.
func TrustLocal ¶ added in v1.3.0
func TrustLocal() ImageOption
TrustLocal lets a failed pull fall back to any local image by that name, not only one this process pulled. For a single-tenant node, where every local image is its owner's.
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.
type PullStatus ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
backends
|
|
|
conformance
Package conformance holds the behaviour every container backend must exhibit.
|
Package conformance holds the behaviour every container backend must exhibit. |
|
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 |