Documentation
¶
Overview ¶
Package vm holds the dashboard's viewmodels: pure Go state over the engine.Engine interface, natively testable, with no widget in sight. The views (package ui) bind to the observables here and call the actions; every action goes through the engine's API, so the terminal and any other client see its effect, and each one names the wctr command line it stands for.
Threading: observables are touched on one goroutine only, the UI's. Work that waits on the engine runs on its own goroutine and hands its result back through the post function the App is given (an mvvm.Queue's Post in the browser, drained at the start of each frame).
Index ¶
- Constants
- Variables
- func Ago(now, t time.Time) string
- func Clean(s string, max int) string
- func Line(args ...string) string
- func Quote(s string) string
- func RelayOrigin(s string) (string, error)
- func ShortID(id string) string
- func Size(n int64) string
- func Sync[T comparable](l *mvvm.ObservableList[T], want []T, key func(T) string)
- func ToSurface(img Box, w, h, px, py int) (x, y float64, ok bool)
- type App
- type Box
- type CLI
- type Class
- type ClassHost
- type ClassStatus
- type ContainerRow
- type Containers
- func (c *Containers) Counts() (running, total int)
- func (c *Containers) Find(id string) (ContainerRow, bool)
- func (c *Containers) Remove(r ContainerRow)
- func (c *Containers) RemoveLine(r ContainerRow) string
- func (c *Containers) Restart(r ContainerRow)
- func (c *Containers) RestartLine(r ContainerRow) string
- func (c *Containers) Start(r ContainerRow)
- func (c *Containers) StartLine(r ContainerRow) string
- func (c *Containers) Stop(r ContainerRow)
- func (c *Containers) StopLine(r ContainerRow) string
- type Detail
- type ExecShell
- type Frame
- type ImageRow
- type Images
- type InspectNode
- type KeyModifiers
- type NetworkRow
- type Networks
- type RunForm
- type Shell
- type SurfaceInput
- type SurfaceRow
- type Surfaces
- func (s *Surfaces) Close(id uint32)
- func (s *Surfaces) Dismiss(id uint32) bool
- func (s *Surfaces) FPS(id uint32) int
- func (s *Surfaces) Find(id uint32) (SurfaceRow, bool)
- func (s *Surfaces) FlushMoves()
- func (s *Surfaces) Frame(id uint32, seq uint64, w, h int, f Frame)
- func (s *Surfaces) Has(id uint32) bool
- func (s *Surfaces) IDs() []uint32
- func (s *Surfaces) Key(id uint32, kind, code, text string, m KeyModifiers)
- func (s *Surfaces) Open(id uint32, container string, pid uint32, w, h int)
- func (s *Surfaces) Pointer(id uint32, kind string, img Box, px, py int)
- func (s *Surfaces) Presented(id uint32, seq uint64, w, h int)
- func (s *Surfaces) Resize(id uint32, w, h int)
- func (s *Surfaces) SetAck(ack func(surface uint32, seq uint64))
- func (s *Surfaces) SetInput(send func(SurfaceInput))
- func (s *Surfaces) Take(id uint32) (f Frame, seq uint64, w, h int, ok bool)
- type Terminal
- type VolumeRow
- type Volumes
- func (v *Volumes) Create()
- func (v *Volumes) CreateLine() string
- func (v *Volumes) Find(name string) (VolumeRow, bool)
- func (v *Volumes) Prune(all bool)
- func (v *Volumes) PruneLine(all bool) string
- func (v *Volumes) Remove(name string, force bool)
- func (v *Volumes) RemoveLine(name string, force bool) string
- type WctrShell
Constants ¶
const ( ViewContainers = iota ViewImages ViewVolumes ViewNetworks ViewTerminal ViewSurfaces NumViews )
The views, in navigation order.
const ( ColName = iota ColImage ColState ColStatus ColCreated ColID NumContainerCols )
Container table columns.
const ( ColRef = iota ColImageID ColDigest ColSize ColImageCreated NumImageCols )
Image table columns.
const ( PointerDown = "pointer-down" PointerUp = "pointer-up" PointerMove = "pointer-move" KeyDown = "key-down" KeyUp = "key-up" )
The kinds of a surface input event (go-wasmcontainers/gpu webgpu.InputKinds).
const (
DefaultSurfaceW, DefaultSurfaceH = 640, 480
MaxSurfaceW, MaxSurfaceH = 1920, 1080
MaxSurfaces = 16
)
Surface limits: the size a surface opens at when it says none, the largest one accepted, how many panes there can be, and how many presentation times the frame-rate window keeps.
const ( VolumesUnknown = iota VolumesUnsupported VolumesSupported )
Volume support, as the engine answered.
const MaxContainers = 2000
MaxContainers bounds the rows the dashboard keeps.
const MaxHistory = 60
MaxHistory bounds the memory readings kept for the sparkline.
const MaxImages = 2000
MaxImages bounds the rows kept.
const PollInterval = 2 * time.Second
PollInterval is how often the dashboard refreshes when the engine has no event stream.
Variables ¶
var ( ReconnectDelay = 200 * time.Millisecond MaxReconnectDelay = 5 * time.Second )
Reconnection delays of the event stream: the first retry, and the most it backs off to while the stream keeps ending without an event.
var Builtins = []cli.Candidate{
{Value: "wctr", Description: "the container CLI"},
{Value: "help", Description: "what this terminal does"},
{Value: "clear", Description: "clear the screen"},
}
Builtins are the shell's own words, for completion.
var ContainerColumns = [NumContainerCols]string{"Name", "Image", "State", "Status", "Created", "ID"}
ContainerColumns are the column titles.
var ImageColumns = [NumImageCols]string{"Repository:Tag", "Image ID", "Digest", "Size", "Created"}
ImageColumns are the column titles.
var NetworkColumns = []string{"Name", "ID", "Driver", "Subnet", "Containers"}
NetworkColumns are the column titles.
var ShellCmd = []string{"/bin/sh"}
ShellCmd is what Open runs in the container. (An exec into a container that has started but has no process yet waits for it in the engine, v0.29.1, so there is nothing to retry here.)
var ViewNames = [NumViews]string{"Containers", "Images", "Volumes", "Networks", "Terminal", "Surfaces"}
ViewNames are the navigation labels.
var VolumeColumns = []string{"Name", "Driver", "Mountpoint", "Created", "Size", "Used by"}
VolumeColumns are the column titles.
Functions ¶
func Clean ¶
Clean makes a container-provided string safe to show as one line of text: control characters (C0, DEL, C1) and Unicode format characters (bidi overrides, zero-width joiners) become U+FFFD or are dropped, and the result is bounded to max runes. Names, labels, commands and images all come from the container's side; nothing of theirs is interpreted.
func Quote ¶
Quote quotes one word for a POSIX shell when it needs it, so a command line shown as a teaching aid can be pasted as is.
func RelayOrigin ¶ added in v0.5.0
RelayOrigin turns what the user typed into the relay's origin, https://host[:port]. A wss:// address names the same relay (its data channel) and maps to https://. Anything else is refused: another scheme, a user or password, a path, a query, a fragment, a host a name cannot be, a port out of range — the origin goes into the engine worker's URL and its CSP, so it must be exactly an origin.
func Sync ¶
func Sync[T comparable](l *mvvm.ObservableList[T], want []T, key func(T) string)
Sync makes l equal to want with as few list events as it can: rows are matched by key, a row that did not change emits nothing, a changed one one Set, a moved one one Move. A refresh that finds the engine as it was therefore costs no event and no redraw. Keys must be unique in want.
Types ¶
type App ¶
type App struct {
// View is the navigation selection (ViewContainers ...).
View *mvvm.Observable[int]
// LastCommand is the wctr command line the last action stands for.
LastCommand *mvvm.Observable[string]
// Error is the last failure, "" when the last action succeeded.
Error *mvvm.Observable[string]
// EngineVersion, Summary and Storage feed the status bar.
EngineVersion *mvvm.Observable[string]
Summary *mvvm.Observable[string]
Storage *mvvm.Observable[string]
// Live says how the dashboard keeps up: "live (events)" or polling.
Live *mvvm.Observable[string]
Containers *Containers
Images *Images
Volumes *Volumes
Networks *Networks
Class *Class
Surfaces *Surfaces
Detail *Detail
Terminal *Terminal
// ExecShell is the shell inside the shown container (`wctr exec -it`).
ExecShell *ExecShell
// Refreshed counts completed refreshes (tests wait on it).
Refreshed *mvvm.Observable[int]
// Pending counts actions under way (the view shows it busy).
Pending *mvvm.Observable[int]
// contains filtered or unexported fields
}
App is the dashboard's root viewmodel.
func NewApp ¶
NewApp builds the viewmodels over eng. cli is the wctr command tree (for the command lines shown), post runs a function on the UI goroutine.
func (*App) Do ¶
Do runs an action against the engine in the background: line is the wctr command line it stands for (shown, and echoed in the terminal when asked), fn the API calls. The dashboard refreshes when it is done.
func (*App) Refresh ¶
func (a *App) Refresh()
Refresh re-reads the engine in the background and applies what changed. Calls while one is running coalesce into one more.
func (*App) Refreshing ¶
Refreshing reports whether a refresh is under way (or queued).
func (*App) RunLive ¶
RunLive keeps the dashboard current until ctx ends. It follows the engine's event stream (GET /events), refreshing on each event. When the stream ends — the engine cuts off a slow reader, or the connection breaks — it resynchronises (a full refresh) and reconnects from the time of the last event it saw, backing off while the stream keeps failing. An engine that serves no event stream is polled every interval instead.
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI knows which commands the wctr in use has, so the dashboard shows the command line a button stands for, or, where wctr has no such command yet, the API call it makes.
func (*CLI) Equivalent ¶
Equivalent is the command line for the wctr command args[0], or, when wctr has no such command, the API call (method and path) with a note.
type Class ¶ added in v0.5.0
type Class struct {
// Available says whether this page can join a class at all.
Available *mvvm.Observable[bool]
// Open is the dialog's visibility.
Open *mvvm.Observable[bool]
// RelayInput, Name and Code are the dialog's fields.
RelayInput, Name, Code *mvvm.Observable[string]
// Relay is the relay the engine runs with ("" none: the dialog asks
// for one first).
Relay *mvvm.Observable[string]
// Status is the last report; Busy while a join or leave is under way.
Status *mvvm.Observable[ClassStatus]
Busy *mvvm.Observable[bool]
// Error is the dialog's message.
Error *mvvm.Observable[string]
// contains filtered or unexported fields
}
Class is the "Join class" dialog and status. The join code is a secret: it lives in Code only until Join, is never part of a command line, a message, a log or the test hook, and is cleared whether or not the join succeeds.
func (*Class) Cancel ¶ added in v0.5.0
func (c *Class) Cancel()
Cancel closes the dialog and forgets the code.
func (*Class) ChangeRelay ¶ added in v0.5.0
func (c *Class) ChangeRelay()
ChangeRelay forgets the relay (the engine restarts without it).
func (*Class) Continue ¶ added in v0.5.0
func (c *Class) Continue()
Continue validates the relay address and restarts the engine with it.
func (*Class) Join ¶ added in v0.5.0
func (c *Class) Join()
Join sends the code and the name. The code leaves Code at once.
func (*Class) Report ¶ added in v0.5.0
func (c *Class) Report(st ClassStatus)
Report applies a status from the engine. Every string is the engine's and is cleaned; an error never carries the code (the engine's rule, and the code is not kept here to leak).
type ClassHost ¶ added in v0.5.0
type ClassHost interface {
// Relay is the relay origin the engine was started with ("" none).
Relay() string
// UseRelay remembers origin (not a secret) and restarts the engine
// with it ("" forgets it); the page reloads.
UseRelay(origin string) error
// Join sends the join code, once, with the name asked for.
Join(code, name string) error
// Leave leaves the class.
Leave() error
}
ClassHost is the page around the dashboard, which owns the engine worker: the relay it was started with, restarting it with another, and the join and leave messages. Status reports come back through App.Class.Report. A host that cannot join a class is nil.
type ClassStatus ¶ added in v0.5.0
type ClassStatus struct {
// State is "joined", "left", "error", or "" before any report.
State string
Relay, Label, Domain, Network, Subnet string
Error string
}
ClassStatus is what the engine reports about the class (the engine worker's {t:"class"} message).
type ContainerRow ¶
type ContainerRow struct {
ID, Name, Image, Command string
State, Status, Created string
CreatedAt int64
}
ContainerRow is one container as the table shows it. Every string is already cleaned (see Clean).
func (ContainerRow) Cells ¶
func (r ContainerRow) Cells() []string
Cells is the row as table cells, in ContainerColumns order.
func (ContainerRow) ExitCode ¶
func (r ContainerRow) ExitCode() (int, bool)
ExitCode parses the exit status out of an "Exited (N) …" status.
func (ContainerRow) Ref ¶
func (r ContainerRow) Ref() string
Ref is the name the command lines use: the name, else the short ID.
func (ContainerRow) Running ¶
func (r ContainerRow) Running() bool
Running reports whether the container runs.
type Containers ¶
type Containers struct {
// Rows are the containers shown (filtered, sorted).
Rows *mvvm.ObservableList[ContainerRow]
// ShowAll shows stopped containers too (`wctr ps -a`).
ShowAll *mvvm.Observable[bool]
// Search filters by name, image, ID or command.
Search *mvvm.Observable[string]
// SortCol / SortAsc order the rows.
SortCol *mvvm.Observable[int]
SortAsc *mvvm.Observable[bool]
// Selected is the selected container's ID ("" for none).
Selected *mvvm.Observable[string]
// contains filtered or unexported fields
}
Containers is the containers view.
func (*Containers) Counts ¶
func (c *Containers) Counts() (running, total int)
Counts is how many containers run and exist.
func (*Containers) Find ¶
func (c *Containers) Find(id string) (ContainerRow, bool)
Find returns the row of the container with id (any shown or hidden).
func (*Containers) Remove ¶
func (c *Containers) Remove(r ContainerRow)
Remove removes the container (forced when it runs).
func (*Containers) RemoveLine ¶
func (c *Containers) RemoveLine(r ContainerRow) string
RemoveLine is rm, forced for a running container.
func (*Containers) Restart ¶
func (c *Containers) Restart(r ContainerRow)
Restart stops the container if it runs and starts it again.
func (*Containers) RestartLine ¶
func (c *Containers) RestartLine(r ContainerRow) string
RestartLine is `wctr restart`.
func (*Containers) StartLine ¶
func (c *Containers) StartLine(r ContainerRow) string
StartLine, StopLine, RestartLine and RemoveLine are the command lines the actions stand for.
func (*Containers) Stop ¶
func (c *Containers) Stop(r ContainerRow)
Stop stops the container; the engine answers once it has exited, so the refresh that follows shows it stopped.
func (*Containers) StopLine ¶
func (c *Containers) StopLine(r ContainerRow) string
StopLine is `wctr stop` (a wasm guest has no signals: it stops at once).
type Detail ¶
type Detail struct {
// ID is the container shown ("" for none).
ID *mvvm.Observable[string]
Title *mvvm.Observable[string]
State *mvvm.Observable[string]
Tree *mvvm.ObservableList[InspectNode]
Env *mvvm.ObservableList[string]
// Mounts lists "source -> destination"; empty with a note when none.
Mounts *mvvm.ObservableList[string]
// Networks lists "network address (dns names)", one per network the
// container is on (addresses while it runs).
Networks *mvvm.ObservableList[string]
// Follow streams new log output as it comes (`wctr logs -f`).
Follow *mvvm.Observable[bool]
// LogsLine is the command line the logs pane stands for.
LogsLine *mvvm.Observable[string]
// LogOut receives log output (already demultiplexed; stderr in red)
// and LogReset clears the log pane; both are set by the view and
// called on the UI goroutine.
LogOut func([]byte)
LogReset func()
// Stats: Memory is the share of the memory limit in use (0..1, -1 when
// unknown), MemoryText the same in bytes, MemHistory the last readings
// (bytes, oldest first, bounded), CPU "--" (the engine does not measure
// it) with CPUNote saying why, and the other counters as text.
Memory *mvvm.Observable[float64]
MemoryText *mvvm.Observable[string]
MemHistory *mvvm.ObservableList[float64]
CPU *mvvm.Observable[string]
CPUNote *mvvm.Observable[string]
Counters *mvvm.Observable[string]
StatsLine *mvvm.Observable[string]
// contains filtered or unexported fields
}
Detail is the container detail pane: inspect tree, environment, mounts, logs.
type ExecShell ¶ added in v0.7.0
type ExecShell struct {
// Line is the command line this stands for; Status says how it goes:
// starting, running, "exited with status N", or the engine's error.
Line *mvvm.Observable[string]
Status *mvvm.Observable[string]
Running *mvvm.Observable[bool]
// Container is the ID of the container the shell is in ("" none).
Container *mvvm.Observable[string]
// Out receives the output and Reset clears the terminal; both are set
// by the view and called on the UI goroutine.
Out func([]byte)
Reset func()
// contains filtered or unexported fields
}
ExecShell is an interactive shell inside a container (`wctr exec -it CONTAINER sh`): POST /containers/{id}/exec with a terminal, then /exec/{id}/start with the keys as stdin and the raw output streamed back. The engine does the line discipline and echo; the view's terminal shows the output (its screen discards every OSC/DCS/APC string) and hands the keys back as bytes.
func (*ExecShell) Close ¶ added in v0.7.0
func (sh *ExecShell) Close()
Close hangs up the shell, if one runs.
func (*ExecShell) Input ¶ added in v0.7.0
Input sends keys (the terminal's bytes) to the shell. Keys typed before it runs wait (bounded); past the bound they are dropped, and said so.
type Frame ¶ added in v0.6.0
type Frame interface{ Close() }
Frame is one presented image of a GPU surface: an ImageBitmap in the browser. Whoever holds it closes it, exactly once.
type ImageRow ¶
type ImageRow struct {
Ref, ID, Digest, Size, Created string
SizeBytes, CreatedAt int64
Containers int64
}
ImageRow is one repository:tag of an image, as `wctr images` lists it.
type Images ¶
type Images struct {
Rows *mvvm.ObservableList[ImageRow]
Search *mvvm.Observable[string]
Selected *mvvm.Observable[string] // row Key
// PullRef is the pull dialog's reference; Pulling says a pull runs;
// PullLog is its progress, one line per message.
PullRef *mvvm.Observable[string]
Pulling *mvvm.Observable[bool]
PullLog *mvvm.ObservableList[string]
Run *RunForm
// contains filtered or unexported fields
}
Images is the images view, with its pull and run dialogs.
type InspectNode ¶
type InspectNode struct {
Depth int
Key, Value string
// Branch is an object or array (its children follow it, one deeper).
Branch bool
}
InspectNode is one line of the inspect tree, in document order.
func InspectTree ¶
func InspectTree(doc []byte) ([]InspectNode, error)
InspectTree flattens a JSON document into tree lines, keeping the document's key order; values are cleaned, the tree is bounded.
type KeyModifiers ¶ added in v0.8.0
type KeyModifiers struct{ Alt, Ctrl, Meta, Shift bool }
KeyModifiers are the modifier keys of a key event.
type NetworkRow ¶ added in v0.5.0
type NetworkRow struct {
Name, ID, Driver, Subnet string
// Containers is how many containers are attached, Attached who they
// are and their addresses ("web 10.42.0.2, db 10.42.0.3").
Containers int
Attached string
}
NetworkRow is one network.
func (NetworkRow) Cells ¶ added in v0.5.0
func (r NetworkRow) Cells() []string
Cells is the row as table cells.
type Networks ¶ added in v0.5.0
type Networks struct {
Rows *mvvm.ObservableList[NetworkRow]
Supported *mvvm.Observable[int]
// Message explains an empty or unavailable view.
Message *mvvm.Observable[string]
// Selected is the selected network's name.
Selected *mvvm.Observable[string]
// NewName is the create field.
NewName *mvvm.Observable[string]
// Inspect is the selected network's inspect document as a tree.
Inspect *mvvm.ObservableList[InspectNode]
// contains filtered or unexported fields
}
Networks is the networks view: list, create, inspect, remove, each naming its `wctr network …` line. An engine that does not serve GET /networks gets a message saying so, never invented rows.
func (*Networks) Create ¶ added in v0.5.0
func (n *Networks) Create()
Create creates a network named NewName (an in-engine bridge).
func (*Networks) CreateLine ¶ added in v0.5.0
CreateLine is the create field's command line.
func (*Networks) Find ¶ added in v0.5.0
func (n *Networks) Find(name string) (NetworkRow, bool)
Find returns the row of the network name.
func (*Networks) InspectLine ¶ added in v0.5.0
InspectLine is the command line the inspect pane stands for.
func (*Networks) RemoveLine ¶ added in v0.5.0
RemoveLine is the command line of Remove.
type RunForm ¶
type RunForm struct {
// Image, Name, Command (shell words), Env (one KEY=value per line or
// comma), Entrypoint, Workdir and Memory mirror wctr run's arguments.
Image, Name, Command, Env *mvvm.Observable[string]
Entrypoint, Workdir, Memory *mvvm.Observable[string]
// Volumes are the -v mounts: NAME:/path[:ro], comma or line separated.
Volumes *mvvm.Observable[string]
AutoRemove *mvvm.Observable[bool]
// Line is the command line the form stands for, Error what is wrong
// with it ("" when it can run).
Line, Error *mvvm.Observable[string]
// Started is the ID of the last container the form started.
Started *mvvm.Observable[string]
// contains filtered or unexported fields
}
RunForm is the run dialog: the options of `wctr run -d`.
type Shell ¶
type Shell interface {
Run(ctx context.Context, line string, out io.Writer) (code int, clear bool)
}
Shell runs one command line, writing its output to out, and returns the exit status and whether the screen should be cleared. The playground's session has this shape; WctrShell is the dashboard's own.
type SurfaceInput ¶ added in v0.8.0
type SurfaceInput struct {
Surface uint32
Kind string
X, Y float64 // pointers: surface pixels
Code, Text string // keys: KeyboardEvent.code, the text it produces
Alt, Ctrl, Meta, Shift bool
}
SurfaceInput is one event for a surface's guest: {t:"input", ...}, which the engine worker hands to webgpu.SurfaceInput.
type SurfaceRow ¶ added in v0.6.0
type SurfaceRow struct {
ID uint32
Title string
Status string
W, H int
// Closed: the guest closed the surface; the pane keeps its last frame,
// greyed, until it is dismissed.
Closed bool
// Shown: a frame has been presented (the pane has an image to draw).
Shown bool
}
SurfaceRow is one surface pane.
type Surfaces ¶ added in v0.6.0
type Surfaces struct {
// Rows are the panes, by surface ID.
Rows *mvvm.ObservableList[SurfaceRow]
// contains filtered or unexported fields
}
Surfaces holds the GPU surfaces the engine reports: the panes, and the newest frame of each until it is presented. Every frame it is given is closed and acknowledged exactly once: presented, replaced by a newer one, for a surface that is unknown or closed, or out of order. The engine paces its guest on those acknowledgements, so none may be lost.
func (*Surfaces) Close ¶ added in v0.6.0
Close marks a surface closed; its pane keeps the last frame, greyed.
func (*Surfaces) Dismiss ¶ added in v0.6.0
Dismiss removes a pane, and reports whether there was one (the view then forgets its image).
func (*Surfaces) Find ¶ added in v0.6.0
func (s *Surfaces) Find(id uint32) (SurfaceRow, bool)
Find returns the pane of surface id.
func (*Surfaces) FlushMoves ¶ added in v0.8.0
func (s *Surfaces) FlushMoves()
FlushMoves sends the pointer moves that waited for this frame.
func (*Surfaces) Frame ¶ added in v0.6.0
Frame takes frame seq of surface id. Only the newest is kept: an older one still waiting is closed and acknowledged as dropped, and so is a frame for a surface that is unknown or closed, or one that does not come after the last.
func (*Surfaces) Has ¶ added in v0.6.0
Has reports whether surface id has a pane (whatever the rows show while they are being rewritten).
func (*Surfaces) Key ¶ added in v0.8.0
func (s *Surfaces) Key(id uint32, kind, code, text string, m KeyModifiers)
Key sends a key event to surface id: its code, the text it produces (bounded; "" when it is too long), and the modifiers.
func (*Surfaces) Open ¶ added in v0.6.0
Open adds the pane of a surface (or reopens one with the same ID).
func (*Surfaces) Pointer ¶ added in v0.8.0
Pointer sends a pointer event at canvas pixel (px, py) to surface id, drawn in img; outside the image it is dropped. Moves are coalesced: the last one waits for FlushMoves (once a frame), and any other event sends the waiting move first, so the guest sees them in order.
func (*Surfaces) Presented ¶ added in v0.6.0
Presented acknowledges frame seq of surface id, drawn, and counts it in the frame rate.
func (*Surfaces) SetAck ¶ added in v0.6.0
SetAck sets how a frame is acknowledged to the engine ({t:"frame-ack"}).
func (*Surfaces) SetInput ¶ added in v0.8.0
func (s *Surfaces) SetInput(send func(SurfaceInput))
SetInput sets where surface input goes (the engine worker); nil drops it.
type Terminal ¶
type Terminal struct {
// Out receives everything to draw and Clear clears the screen; both
// are set by Attach and called on the UI goroutine.
Out func(string)
Clear func()
// ShowActions echoes each dashboard action's command line here.
ShowActions *mvvm.Observable[bool]
// Running says a command runs (only Ctrl-C reaches it).
Running *mvvm.Observable[bool]
// contains filtered or unexported fields
}
Terminal is the terminal view's model: the engine's line editor (cli/lineedit, the one the playground uses) in front of a Shell. Input arrives as the bytes a terminal sends; output goes to Out (the view's terminal widget, which is safe for untrusted output by construction).
Keys are handled on the terminal's own goroutine, never the UI's: Tab completion asks the engine (container names) and must not block the page's event loop, which is what delivers the engine's answer.
func (*Terminal) Attach ¶
Attach connects the view and starts the terminal: greeting, prompt, and the goroutine that handles keys. Called on the UI goroutine.
func (*Terminal) Input ¶
Input queues what the user typed. It never blocks (keys past a full queue are dropped).
type VolumeRow ¶
type VolumeRow struct {
Name, Driver, Mountpoint, Created, Size string
// Used is how many containers reference it ("" when unknown).
Used string
}
VolumeRow is one volume.
type Volumes ¶
type Volumes struct {
Rows *mvvm.ObservableList[VolumeRow]
Supported *mvvm.Observable[int]
// Message explains an empty or unavailable view.
Message *mvvm.Observable[string]
// Selected is the selected volume's name.
Selected *mvvm.Observable[string]
// NewName is the create field.
NewName *mvvm.Observable[string]
// Inspect is the selected volume's inspect document as a tree.
Inspect *mvvm.ObservableList[InspectNode]
// Notice is the last prune's result.
Notice *mvvm.Observable[string]
// contains filtered or unexported fields
}
Volumes is the volumes view: list, create, inspect, remove, prune, each naming its `wctr volume …` line. An engine that does not serve GET /volumes gets a message saying so, never invented rows.
func (*Volumes) Create ¶ added in v0.3.0
func (v *Volumes) Create()
Create creates a volume named NewName (the engine names it when empty).
func (*Volumes) CreateLine ¶ added in v0.3.0
CreateLine is the create field's command line.
func (*Volumes) Prune ¶ added in v0.3.0
Prune removes unused volumes (anonymous ones, or with all every unused one) and says what it reclaimed.