Documentation
¶
Overview ¶
Package driver is the builder's view of the engine: the operations a build needs (inspect, pull, load, tag, create, archive in and out, run, commit), and Client, which performs them over the engine's API — the subset of the Docker Engine API that wctrd serves, plus the endpoints a builder needs from it (commit, tag, load, container archives).
Index ¶
- Constants
- Variables
- func StripVersion(base string) string
- type Client
- func (c *Client) Commit(ctx context.Context, spec CommitSpec) (string, error)
- func (c *Client) CreateContainer(ctx context.Context, spec RunSpec) (string, error)
- func (c *Client) GetArchive(ctx context.Context, id, p string) (io.ReadCloser, error)
- func (c *Client) InspectImage(ctx context.Context, ref string) (*Image, error)
- func (c *Client) LoadImage(ctx context.Context, layout io.Reader) (string, error)
- func (c *Client) PullImage(ctx context.Context, ref string, progress io.Writer) error
- func (c *Client) PutArchive(ctx context.Context, id, dir string, tar io.Reader) error
- func (c *Client) RemoveContainer(ctx context.Context, id string) error
- func (c *Client) Run(ctx context.Context, id string, stdout, stderr io.Writer) (int, error)
- func (c *Client) StatPath(ctx context.Context, id, p string) (bool, error)
- func (c *Client) TagImage(ctx context.Context, image, repo, tag string) error
- type CommitSpec
- type Engine
- type ExitError
- type HealthConfig
- type Image
- type ImageConfig
- type RunSpec
Constants ¶
const ( ExitNotExecutable = 126 ExitMissing = 127 )
Exit statuses the engine uses (engine/runtime).
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound reports a missing image or container.
Functions ¶
func StripVersion ¶ added in v0.2.1
StripVersion removes a trailing "/vMAJOR.MINOR" (and slashes) from base.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client speaks the engine's API.
func NewClient ¶
NewClient talks to base through hc: a unix-socket transport natively, the engine's in-process transport in a browser. base may or may not end with an API version ("http://wctr" or "http://wctr/v1.47", which is what the engine's api.Client.HTTP returns): the version is never doubled, and requests always go to this client's API version.
func (*Client) CreateContainer ¶
CreateContainer implements Engine.
func (*Client) GetArchive ¶
GetArchive implements Engine.
func (*Client) InspectImage ¶
InspectImage implements Engine.
func (*Client) PutArchive ¶
PutArchive implements Engine.
func (*Client) RemoveContainer ¶
RemoveContainer implements Engine.
func (*Client) Run ¶
Run implements Engine: register the wait, follow the logs, start, and copy the output while the step runs. The log stream is opened before the start (the engine follows a created container until it has run), so nothing is missed, however fast the step, and it ends when the step exits.
type CommitSpec ¶
type CommitSpec struct {
Container string
// Repo and Tag name the image; empty leaves it addressable by ID only.
Repo, Tag string
Comment string
Author string
// Config replaces the container's configuration in the image.
Config ImageConfig
}
CommitSpec makes an image of a container.
type Engine ¶
type Engine interface {
// InspectImage returns ErrNotFound (wrapped) for a missing image.
InspectImage(ctx context.Context, ref string) (*Image, error)
// PullImage fetches ref for platform wasip1/wasm.
PullImage(ctx context.Context, ref string, progress io.Writer) error
// LoadImage imports an OCI image layout sent as a tar and returns the
// ID of the image it named (or of its only image).
LoadImage(ctx context.Context, layout io.Reader) (string, error)
TagImage(ctx context.Context, image, repo, tag string) error
CreateContainer(ctx context.Context, spec RunSpec) (string, error)
// PutArchive extracts a tar into the container at dir.
PutArchive(ctx context.Context, id, dir string, tar io.Reader) error
// StatPath reports whether path exists in the container (HEAD on the
// archive endpoint: no content is sent).
StatPath(ctx context.Context, id, path string) (bool, error)
// GetArchive returns a tar of path, its base name as the root entry.
GetArchive(ctx context.Context, id, path string) (io.ReadCloser, error)
// Run starts the container, copies its output, and returns its exit
// status once it exits. A module that cannot be started is reported
// as its exit status (127 missing, 126 not executable) with the
// engine's message in err of type *ExitError.
Run(ctx context.Context, id string, stdout, stderr io.Writer) (int, error)
Commit(ctx context.Context, spec CommitSpec) (string, error)
RemoveContainer(ctx context.Context, id string) error
}
Engine is what a build drives.
type HealthConfig ¶
type HealthConfig struct {
Test []string `json:"Test,omitempty"`
Interval int64 `json:"Interval,omitempty"`
Timeout int64 `json:"Timeout,omitempty"`
StartPeriod int64 `json:"StartPeriod,omitempty"`
StartInterval int64 `json:"StartInterval,omitempty"`
Retries int `json:"Retries,omitempty"`
}
HealthConfig is an image's HEALTHCHECK (Docker's image config field). Durations are nanoseconds, as Docker stores them.
type Image ¶
type Image struct {
ID string
OS string
Architecture string
Author string
Config ImageConfig
// Layers is the number of layers (bounded by the engine).
Layers int
}
Image is what the builder needs to know of an image.
type ImageConfig ¶
type ImageConfig struct {
User string `json:"User,omitempty"`
ExposedPorts map[string]struct{} `json:"ExposedPorts,omitempty"`
Env []string `json:"Env,omitempty"`
Entrypoint []string `json:"Entrypoint,omitempty"`
Cmd []string `json:"Cmd,omitempty"`
Volumes map[string]struct{} `json:"Volumes,omitempty"`
WorkingDir string `json:"WorkingDir,omitempty"`
Labels map[string]string `json:"Labels,omitempty"`
StopSignal string `json:"StopSignal,omitempty"`
Shell []string `json:"Shell,omitempty"`
OnBuild []string `json:"OnBuild,omitempty"`
Healthcheck *HealthConfig `json:"Healthcheck,omitempty"`
}
ImageConfig is the "config" object of an image config: the OCI fields plus Docker's Shell, OnBuild and Healthcheck.
type RunSpec ¶
type RunSpec struct {
Image string
// Entrypoint is the command; the image's Cmd is dropped.
Entrypoint []string
// Env is added to the image's (same key: this wins).
Env []string
WorkingDir string
User string
// Network: "" (the engine's default) or "none".
Network string
}
RunSpec makes a container for one build step.