sharedvm

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMounts

func DefaultMounts(workspaceDirs []string) map[string]string

DefaultMounts returns mount mappings from workspace dirs. Each host dir is mounted at /host<dir> inside the VM. e.g., /Users/adrian → /host/Users/adrian

func DeleteVMState

func DeleteVMState() error

func MountFlags

func MountFlags(mounts map[string]string) []string

MountFlags returns -v flags for VM creation from the mount mapping.

func ResolveMountParent added in v0.6.0

func ResolveMountParent(path string) (string, error)

ResolveMountParent determines which directory to mount for a given path. If the path is a directory, it returns that directory. If the path is a file (or doesn't exist), it walks up to find the nearest existing parent directory. Symlinks in the input are resolved before the blocklist check, so a symlink pointing at a blocked system root is rejected. Returns an error if the resolved directory is a blocked broad system root or if the path is not absolute.

func SaveVMState

func SaveVMState(s *VMState) error

func TranslatePath

func TranslatePath(hostPath string, mounts map[string]string) (string, bool)

TranslatePath converts a host-absolute path to its VM-internal path. Returns (translated, true) if a mount covers the path, or (original, false) if not.

func TranslateVolumeSpec

func TranslateVolumeSpec(spec string, mounts map[string]string) (string, error)

TranslateVolumeSpec rewrites a volume spec's host path. Returns an error if the host path is absolute but not covered by any mount.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles the lifecycle of the persistent shared VM.

func NewManager

func NewManager(apple engine.Runtime, cfg config.SharedVM) *Manager

func NewManagerWithName added in v0.6.0

func NewManagerWithName(apple engine.Runtime, cfg config.SharedVM, name string) *Manager

NewManagerWithName creates a manager for a VM with a custom name. Used for per-project compose VMs in full isolation mode.

func (*Manager) EnsureRunning

func (m *Manager) EnsureRunning(ctx context.Context) error

EnsureRunning ensures the shared VM is running, creating it if needed.

func (*Manager) ExpandMounts added in v0.6.0

func (m *Manager) ExpandMounts(ctx context.Context, paths []string) error

ExpandMounts adds new host paths to the VM's mount set. Since Apple Container only accepts -v at creation time, this requires stopping and recreating the VM. Returns an error if containers are running inside the VM.

func (*Manager) Mounts

func (m *Manager) Mounts() map[string]string

Mounts returns the host→VM path mappings.

func (*Manager) Name added in v0.6.0

func (m *Manager) Name() string

Name returns the VM container name.

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context) error

Remove force-removes the shared VM and cleans up state.

func (*Manager) Status

func (m *Manager) Status(ctx context.Context) string

Status returns the current VM status: "running", "stopped", or "".

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context) error

Stop stops the shared VM.

func (*Manager) VMIP added in v0.5.0

func (m *Manager) VMIP(ctx context.Context) string

VMIP returns the shared VM's IP address, or "" if unavailable.

type SharedVMRuntime

type SharedVMRuntime struct {
	// contains filtered or unexported fields
}

SharedVMRuntime implements engine.Runtime by proxying all operations into a persistent shared VM. Each method constructs a gocker CLI command and executes it via `container exec gocker-shared gocker <args>`.

func NewSharedVMRuntime

func NewSharedVMRuntime(manager *Manager, apple engine.Runtime) *SharedVMRuntime

func (*SharedVMRuntime) BinaryPath

func (s *SharedVMRuntime) BinaryPath() string

func (*SharedVMRuntime) ContainerExec

func (s *SharedVMRuntime) ContainerExec(ctx context.Context, nameOrID string, args []string, interactive bool) error

func (*SharedVMRuntime) ContainerInspect

func (s *SharedVMRuntime) ContainerInspect(ctx context.Context, nameOrID string) ([]byte, error)

func (*SharedVMRuntime) ContainerList

func (s *SharedVMRuntime) ContainerList(ctx context.Context, all bool) ([]engine.ContainerInfo, error)

func (*SharedVMRuntime) ContainerLogs

func (s *SharedVMRuntime) ContainerLogs(ctx context.Context, nameOrID string, follow bool) error

func (*SharedVMRuntime) ContainerRemove

func (s *SharedVMRuntime) ContainerRemove(ctx context.Context, nameOrID string, force bool) error

func (*SharedVMRuntime) ContainerRun

func (s *SharedVMRuntime) ContainerRun(ctx context.Context, args []string, interactive bool) error

func (*SharedVMRuntime) ContainerStart

func (s *SharedVMRuntime) ContainerStart(ctx context.Context, nameOrID string) error

func (*SharedVMRuntime) ContainerStop

func (s *SharedVMRuntime) ContainerStop(ctx context.Context, nameOrID string) error

func (*SharedVMRuntime) Exec

func (s *SharedVMRuntime) Exec(ctx context.Context, args ...string) ([]byte, []byte, error)

func (*SharedVMRuntime) ExecInteractive

func (s *SharedVMRuntime) ExecInteractive(ctx context.Context, args ...string) error

func (*SharedVMRuntime) ExecStream

func (s *SharedVMRuntime) ExecStream(ctx context.Context, args ...string) (io.ReadCloser, error)

func (*SharedVMRuntime) ImageBuild

func (s *SharedVMRuntime) ImageBuild(ctx context.Context, args []string) error

func (*SharedVMRuntime) ImageList

func (s *SharedVMRuntime) ImageList(ctx context.Context) ([]engine.ImageInfo, error)

func (*SharedVMRuntime) ImagePull

func (s *SharedVMRuntime) ImagePull(ctx context.Context, image string, opts engine.ImagePullOpts) error

func (*SharedVMRuntime) ImagePush

func (s *SharedVMRuntime) ImagePush(ctx context.Context, image string) error

func (*SharedVMRuntime) ImageRemove

func (s *SharedVMRuntime) ImageRemove(ctx context.Context, image string) error

func (*SharedVMRuntime) NetworkConnect

func (s *SharedVMRuntime) NetworkConnect(ctx context.Context, network, container string) error

func (*SharedVMRuntime) NetworkCreate

func (s *SharedVMRuntime) NetworkCreate(ctx context.Context, name string) error

func (*SharedVMRuntime) NetworkDisconnect

func (s *SharedVMRuntime) NetworkDisconnect(ctx context.Context, network, container string) error

func (*SharedVMRuntime) NetworkInspect

func (s *SharedVMRuntime) NetworkInspect(ctx context.Context, name string) ([]byte, error)

func (*SharedVMRuntime) NetworkList

func (s *SharedVMRuntime) NetworkList(ctx context.Context) ([]engine.NetworkInfo, error)

func (*SharedVMRuntime) NetworkRemove

func (s *SharedVMRuntime) NetworkRemove(ctx context.Context, name string) error

func (*SharedVMRuntime) Validate

func (s *SharedVMRuntime) Validate() error

Validate checks that the Apple runtime exists. The VM itself is created lazily.

func (*SharedVMRuntime) VolumeCreate

func (s *SharedVMRuntime) VolumeCreate(ctx context.Context, name string) error

func (*SharedVMRuntime) VolumeInspect

func (s *SharedVMRuntime) VolumeInspect(ctx context.Context, name string) ([]byte, error)

func (*SharedVMRuntime) VolumeList

func (s *SharedVMRuntime) VolumeList(ctx context.Context) ([]engine.VolumeInfo, error)

func (*SharedVMRuntime) VolumeRemove

func (s *SharedVMRuntime) VolumeRemove(ctx context.Context, name string) error

type VMState

type VMState struct {
	Name    string            `json:"name"`
	Status  string            `json:"status"` // running, stopped
	Image   string            `json:"image"`
	Created time.Time         `json:"created"`
	Mounts  map[string]string `json:"mounts"` // host path -> VM path
}

VMState tracks the persistent shared VM.

func LoadVMState

func LoadVMState() (*VMState, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL