Documentation
¶
Overview ¶
Package engine is what the dashboard needs from a container engine: the calls of an API compatible with the Docker Engine API, as the engine of go-wasmcontainers serves them. The viewmodels depend on the Engine interface only, so they test against a fake as well as against a real engine served in-process.
Endpoints a given engine does not serve (an older engine: volumes, disk usage, the event stream, stats, networks) answer ErrUnsupported, told apart from an ordinary "not found" by the router's own 404 (a plain-text body, not the API's JSON error). The dashboard then says what it needs instead of inventing data.
Index ¶
- Variables
- type DiskUsage
- type Engine
- type Event
- type HTTP
- func (h *HTTP) DiskUsage(ctx context.Context) (DiskUsage, error)
- func (h *HTTP) Events(ctx context.Context, since int64, fn func(Event)) error
- func (h *HTTP) InspectContainer(ctx context.Context, id string) (json.RawMessage, error)
- func (h *HTTP) InspectImage(ctx context.Context, ref string) (json.RawMessage, error)
- func (h *HTTP) Networks(ctx context.Context) ([]Network, error)
- func (h *HTTP) Stats(ctx context.Context, id string, stream bool, fn func(Stats)) error
- func (h *HTTP) Volumes(ctx context.Context) ([]Volume, error)
- type Network
- type Stats
- type Volume
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("not served by this engine")
ErrUnsupported is returned for an endpoint the engine does not serve.
Functions ¶
This section is empty.
Types ¶
type DiskUsage ¶
type DiskUsage = api.SystemDataUsage
DiskUsage is GET /system/df, with the engine's Storage addition.
type Engine ¶
type Engine interface {
Version(ctx context.Context) (api.SystemVersion, error)
Containers(ctx context.Context, all bool) ([]api.ContainerSummary, error)
Images(ctx context.Context) ([]api.ImageSummary, error)
InspectContainer(ctx context.Context, id string) (json.RawMessage, error)
InspectImage(ctx context.Context, ref string) (json.RawMessage, error)
Start(ctx context.Context, id string) error
Kill(ctx context.Context, id string) error
// Stop stops a running container and returns once it has exited.
Stop(ctx context.Context, id string) error
// Restart stops the container if it runs, then starts it.
Restart(ctx context.Context, id string) error
Remove(ctx context.Context, id string, force bool) error
Create(ctx context.Context, name string, req api.ContainerCreateRequest) (api.ContainerCreateResponse, error)
Pull(ctx context.Context, ref string, progress func(api.JSONMessage)) error
RemoveImage(ctx context.Context, ref string, force bool) ([]api.ImageDeleteResponseItem, error)
// Logs returns the multiplexed log stream (see api.Demux).
Logs(ctx context.Context, id string, follow bool) (io.ReadCloser, error)
Volumes(ctx context.Context) ([]Volume, error)
VolumeCreate(ctx context.Context, o api.VolumeCreateOptions) (Volume, error)
VolumeInspect(ctx context.Context, name string) (json.RawMessage, error)
VolumeRemove(ctx context.Context, name string, force bool) error
VolumesPrune(ctx context.Context, all bool) (api.VolumePruneResponse, error)
DiskUsage(ctx context.Context) (DiskUsage, error)
Networks(ctx context.Context) ([]Network, error)
NetworkCreate(ctx context.Context, o api.NetworkCreateRequest) (api.NetworkCreateResponse, error)
NetworkInspect(ctx context.Context, ref string) (json.RawMessage, error)
NetworkRemove(ctx context.Context, ref string) error
// ExecCreate prepares a process in a running container; ExecStart runs
// it, sending stdin (read until it ends) and returning its output
// stream (raw with a terminal); closing the stream hangs up, which
// kills the process. ExecResize sizes its terminal; ExecInspect says
// whether it runs and its exit code.
ExecCreate(ctx context.Context, container string, req api.ExecCreateRequest) (string, error)
ExecStart(ctx context.Context, id string, req api.ExecStartRequest, stdin io.Reader) (io.ReadCloser, error)
ExecResize(ctx context.Context, id string, height, width uint16) error
ExecInspect(ctx context.Context, id string) (api.ExecInspect, error)
// Events calls fn for each event since the given Unix time (0: from
// now) until ctx ends or the stream does (the engine cuts off a slow
// reader: reconnect with since and resynchronise).
Events(ctx context.Context, since int64, fn func(Event)) error
// Stats calls fn with one reading, or one a second while stream holds,
// until ctx ends or the stream does.
Stats(ctx context.Context, id string, stream bool, fn func(Stats)) error
}
Engine is the API the dashboard drives.
type HTTP ¶
HTTP is the Engine over an HTTP client: a unix socket, or the bridge the browser uses.
func New ¶
New speaks to the engine at base (e.g. "http://engine") through hc.
func (*HTTP) InspectContainer ¶
InspectContainer inspects a container.
func (*HTTP) InspectImage ¶
InspectImage inspects an image.
func (*HTTP) Networks ¶ added in v0.5.0
Networks lists networks (ErrUnsupported from an engine without them).
type Stats ¶ added in v0.3.0
type Stats = api.ContainerStats
Stats is one reading of GET /containers/{id}/stats.