Documentation
¶
Overview ¶
Package tartvm implements cloudeng.io/vms.Instance using the tart CLI on macOS.
Index ¶
- Constants
- func DefaultLinuxRunOptions() []string
- func DefaultMacOSRunOptions() []string
- func DefaultRunOptions() []string
- type CloneInfo
- type Instance
- func (inst *Instance) Clone(ctx context.Context) error
- func (inst *Instance) Delete(ctx context.Context) error
- func (inst *Instance) Exec(ctx context.Context, stdout, stderr io.Writer, cmd string, args ...string) error
- func (inst *Instance) ID() string
- func (inst *Instance) Properties(context.Context) (vms.Properties, error)
- func (inst *Instance) Start(ctx context.Context, stdout, stderr io.Writer) error
- func (inst *Instance) State(_ context.Context) vms.State
- func (inst *Instance) Stop(ctx context.Context, timeout time.Duration) (runErr, stopErr error)
- func (inst *Instance) Suspend(ctx context.Context) error
- func (inst *Instance) Suspendable() bool
- type ListEntries
- type ListEntry
- type Option
Constants ¶
const ( DefaultPollingInterval = 100 * time.Millisecond DefaultOutputBufferSize = 16 * 1024 // 16KiB DefaultRunTimeout = 2 * time.Minute DefaultForceStopTimeout = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DefaultLinuxRunOptions ¶
func DefaultLinuxRunOptions() []string
func DefaultMacOSRunOptions ¶
func DefaultMacOSRunOptions() []string
func DefaultRunOptions ¶
func DefaultRunOptions() []string
DefaultRunOptions are safe defaults that work with mac and linux tart VMs. Linux does not currently support suspend.
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance implements vms.Instance backed by the tart CLI. source is the OCI reference used for cloning; name is the local VM name. All images must have the tart agent installed and be compatible with the tart CLI version installed locally.
func New ¶
New returns an Instance in StateInitial, source is the tart image or OCI reference to clone from; name is the local VM name.
func (*Instance) Clone ¶
Clone runs "tart clone <source> <name>" and transitions to StateReadyToRun.
func (*Instance) Exec ¶
func (inst *Instance) Exec(ctx context.Context, stdout, stderr io.Writer, cmd string, args ...string) error
Exec runs "tart exec <name> <cmd> <args...>" with the output connected to the provided writers. It returns when the command completes.
func (*Instance) Properties ¶
Properties returns VM properties. If the VM is running, it returns the IP address.
func (*Instance) Start ¶
Start runs "tart run <name> --no-graphics --suspendable" by starting the tart process in the background, then blocks until tart reports the VM is running, an IP address is available, and a tart exec readiness check succeeds. On success, the instance transitions to StateRunning..
func (*Instance) State ¶
State returns the current state and any error from a running instance that terminated without being stopped or suspend.
func (*Instance) Suspendable ¶
type ListEntries ¶
type ListEntries []ListEntry
func ListAll ¶
func ListAll(ctx context.Context) (ListEntries, error)
ListAll calls "tart list --format json" and returns the entries.
func (ListEntries) Len ¶
func (e ListEntries) Len() int
func (ListEntries) Lookup ¶
func (e ListEntries) Lookup(name string) (ListEntry, bool)
Lookup returns the entry for name, or (zero, false) if the VM is not present.
func (ListEntries) LookupSourceName ¶
func (e ListEntries) LookupSourceName(source, name string) (ListEntry, bool)
LookupSourceName returns the entry for source and name, or (zero, false) if the VM is not present.
type ListEntry ¶
type ListEntry struct {
State string
Name string
Size int
Accessed time.Time
Source string
Disk int
Running bool
}
ListEntry represents an entry in the output of "tart list --format json".
type Option ¶
type Option func(o *options)
Option represents an Option to New.
func WithForceStopTimeout ¶
WithForceStopTimeout sets the timeout for forcefully stopping a VM when a run operation, or other operation, fails and the error recovery needs to stop the VM.
func WithLogger ¶
WithLogger sets a logger to use for logging tart commands and state transitions.
func WithPollingInterval ¶
WithPollingInterval sets the interval to use for polling the state of the VM when waiting for state transitions, network availability, etc.
The default is DefaultPollingInterval.
func WithRunOptions ¶
WithRunOptions sets additional options to pass to the "tart run" command. The default is the value returned by DefaultRunOptions.
func WithRunTimeout ¶
WithRunTimeout sets a timeout for the VM to reach a running state after Start is called. The default is DefaultRunTimeout.