studio

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package studio provides one-click AI development environment management across various container and VM platforms (WSL, Colima, AppleContainer, K8S, Docker).

Index

Constants

View Source
const (
	SSHPortRangeMin = 12000
	SSHPortRangeMax = 18000
)

SSH port range constants

View Source
const (
	// CDN base URL for TensorFusion libraries
	DefaultCDNURL = "https://cdn.tensor-fusion.ai"

	// Library version - this would normally come from config
	DefaultLibVersion = "v1.0.0"
)
View Source
const (
	OSDarwin  = "darwin"
	OSLinux   = "linux"
	OSWindows = "windows"
)

Platform constants for runtime.GOOS comparisons

View Source
const (
	ArchX86_64  = "x86_64"
	ArchAarch64 = "aarch64"
	ArchAmd64   = "amd64"
	ArchArm64   = "arm64"
)

Architecture constants for CPU architecture detection

View Source
const (
	DefaultProtocolTCP      = "tcp"
	MountOptionReadOnly     = ":ro"
	DefaultImageStudioTorch = "tensorfusion/studio-torch:latest"
	DockerStateRunning      = "running"
	DockerStateExited       = "exited"
	DockerStateCreated      = "created"
	DefaultHostLocalhost    = "localhost"
)

Docker-related constants

Variables

This section is empty.

Functions

func BuildContainerArgs added in v1.1.17

func BuildContainerArgs(result *ContainerSetupResult) []string

BuildContainerArgs builds common Docker/container run arguments from setup result This is a helper for backends that use docker-style CLI

func FindActualLibraryFiles added in v1.1.17

func FindActualLibraryFiles(cachePath string, vendor GPUVendor) []string

FindActualLibraryFiles scans the cache directory for actual GPU library files that should be preloaded. This handles cases where downloaded files have different names than the canonical library names.

func FormatContainerCommand added in v1.1.17

func FormatContainerCommand(command []string) []string

FormatContainerCommand formats the command slice for docker/container execution. If a single command string is passed that looks like a shell command (contains spaces or shell metacharacters), it wraps with "sh -c" to ensure proper shell interpretation. This handles cases like: -c "sh -c 'sleep 1d'" or -c "sleep 1d && echo done"

func GenerateBatchScript added in v1.1.7

func GenerateBatchScript(config *GPUEnvConfig, paths *platform.Paths) (string, error)

GenerateBatchScript generates a CMD batch script to set up the GPU environment

func GenerateContainerName added in v1.1.17

func GenerateContainerName(name string) string

GenerateContainerName generates a unique container name with random suffix

func GenerateEnvScript added in v1.1.7

func GenerateEnvScript(config *GPUEnvConfig, paths *platform.Paths) (string, error)

GenerateEnvScript generates a shell script to set up the GPU environment

func GeneratePowerShellScript added in v1.1.7

func GeneratePowerShellScript(config *GPUEnvConfig, paths *platform.Paths) (string, error)

GeneratePowerShellScript generates a PowerShell script to set up the GPU environment

func GetLibraryNames added in v1.1.7

func GetLibraryNames(vendor GPUVendor) []string

GetLibraryNames returns the library names to preload for a vendor (Linux/macOS) Note: These are the expected canonical names. Use FindActualLibraryFiles to discover actual downloaded files which may have different names.

func GetWindowsLibraryNames added in v1.1.7

func GetWindowsLibraryNames(vendor GPUVendor) []string

GetWindowsLibraryNames returns the DLL names for a vendor (Windows)

func IsDarwin added in v1.1.7

func IsDarwin() bool

IsDarwin returns true if running on macOS

func IsLinux added in v1.1.7

func IsLinux() bool

IsLinux returns true if running on Linux

func MergeEnvVars added in v1.1.17

func MergeEnvVars(setupEnvs, userEnvs map[string]string) map[string]string

MergeEnvVars merges user-provided env vars with setup result env vars User-provided vars take precedence

func NormalizeArch added in v1.1.18

func NormalizeArch(arch string) string

NormalizeArch normalizes architecture names to Docker/OCI format (amd64, arm64)

func SSHAuthorizedKeysPath added in v1.1.18

func SSHAuthorizedKeysPath(paths *platform.Paths, studioName string) string

SSHAuthorizedKeysPath returns the path to store authorized_keys for a studio

Types

type AppleContainerBackend

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

AppleContainerBackend implements the Backend interface using Apple native containers.

func NewAppleContainerBackend

func NewAppleContainerBackend() *AppleContainerBackend

NewAppleContainerBackend creates a new Apple container backend.

func (*AppleContainerBackend) Create

func (*AppleContainerBackend) EnsureRunning added in v1.2.0

func (b *AppleContainerBackend) EnsureRunning(ctx context.Context) error

func (*AppleContainerBackend) Exec

func (b *AppleContainerBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)

func (*AppleContainerBackend) Get

func (b *AppleContainerBackend) Get(ctx context.Context, idOrName string) (*Environment, error)

func (*AppleContainerBackend) IsAvailable

func (b *AppleContainerBackend) IsAvailable(ctx context.Context) bool

func (*AppleContainerBackend) IsInstalled added in v1.2.0

func (b *AppleContainerBackend) IsInstalled(ctx context.Context) bool

func (*AppleContainerBackend) List

func (*AppleContainerBackend) Logs

func (b *AppleContainerBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)

func (*AppleContainerBackend) Mode

func (b *AppleContainerBackend) Mode() Mode

func (*AppleContainerBackend) Name

func (b *AppleContainerBackend) Name() string

func (*AppleContainerBackend) Remove

func (b *AppleContainerBackend) Remove(ctx context.Context, envID string) error

func (*AppleContainerBackend) Start

func (b *AppleContainerBackend) Start(ctx context.Context, envID string) error

func (*AppleContainerBackend) Stop

func (b *AppleContainerBackend) Stop(ctx context.Context, envID string) error

type Architecture

type Architecture struct {
	OS   string // darwin, linux, windows
	Arch string // arm64, amd64, 386
}

Architecture detection

func DetectArchitecture

func DetectArchitecture() Architecture

DetectArchitecture detects the current system architecture

func (Architecture) String

func (a Architecture) String() string

String returns the architecture string for CDN lookup

type AutoStartableBackend added in v1.1.10

type AutoStartableBackend interface {
	Backend
	// IsInstalled checks if the backend software is installed (but not necessarily running)
	IsInstalled(ctx context.Context) bool
	// EnsureRunning ensures the backend is running, starting it if necessary
	EnsureRunning(ctx context.Context) error
}

AutoStartableBackend is an optional interface for backends that can be auto-started. Backends implementing this interface can be selected even if not currently running, as long as they are installed and can be started automatically.

type Backend

type Backend interface {
	// Name returns the backend name
	Name() string

	// Mode returns the mode this backend handles
	Mode() Mode

	// IsAvailable checks if this backend is available on the system
	IsAvailable(ctx context.Context) bool

	// Create creates a new environment
	Create(ctx context.Context, opts *CreateOptions) (*Environment, error)

	// Start starts a stopped environment
	Start(ctx context.Context, envID string) error

	// Stop stops a running environment
	Stop(ctx context.Context, envID string) error

	// Remove removes an environment
	Remove(ctx context.Context, envID string) error

	// List lists all environments
	List(ctx context.Context) ([]*Environment, error)

	// Get gets an environment by ID or name
	Get(ctx context.Context, idOrName string) (*Environment, error)

	// Exec executes a command in an environment
	Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)

	// Logs returns logs from an environment
	Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)
}

Backend is the interface for container/VM runtime backends

type BackendSocketPath added in v1.3.0

type BackendSocketPath interface {
	Backend
	SocketPath(ctx context.Context) string
}

BackendSocketPath is an optional interface for backends that use a container unix socket. SocketPath returns the backend's container unix socket path (e.g. DOCKER_HOST or docker.sock path). Empty string means not applicable (e.g. Apple Container).

type ColimaBackend

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

ColimaBackend implements the Backend interface using Colima (macOS/Linux)

func NewColimaBackend

func NewColimaBackend() *ColimaBackend

NewColimaBackend creates a new Colima backend

func NewColimaBackendWithProfile

func NewColimaBackendWithProfile(profile string) *ColimaBackend

NewColimaBackendWithProfile creates a new Colima backend with specific profile

func (*ColimaBackend) Create

func (b *ColimaBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)

func (*ColimaBackend) EnsureRunning

func (b *ColimaBackend) EnsureRunning(ctx context.Context) error

EnsureRunning ensures Colima is running

func (*ColimaBackend) Exec

func (b *ColimaBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)

func (*ColimaBackend) Get

func (b *ColimaBackend) Get(ctx context.Context, idOrName string) (*Environment, error)

func (*ColimaBackend) GetColimaIP

func (b *ColimaBackend) GetColimaIP(ctx context.Context) (string, error)

GetColimaIP returns the IP address of the Colima VM

func (*ColimaBackend) GetProfile

func (b *ColimaBackend) GetProfile() string

GetProfile returns the Colima profile name

func (*ColimaBackend) GetVMArch added in v1.1.18

func (b *ColimaBackend) GetVMArch(ctx context.Context) string

GetVMArch returns the architecture of the Colima VM Returns "amd64", "arm64", or empty string if detection fails

func (*ColimaBackend) IsAvailable

func (b *ColimaBackend) IsAvailable(ctx context.Context) bool

func (*ColimaBackend) IsInstalled added in v1.1.10

func (b *ColimaBackend) IsInstalled(ctx context.Context) bool

IsInstalled checks if colima is installed (but not necessarily running)

func (*ColimaBackend) List

func (b *ColimaBackend) List(ctx context.Context) ([]*Environment, error)

func (*ColimaBackend) Logs

func (b *ColimaBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)

func (*ColimaBackend) Mode

func (b *ColimaBackend) Mode() Mode

func (*ColimaBackend) Name

func (b *ColimaBackend) Name() string

func (*ColimaBackend) Remove

func (b *ColimaBackend) Remove(ctx context.Context, envID string) error

func (*ColimaBackend) SetDockerHost

func (b *ColimaBackend) SetDockerHost(dockerHost string)

SetDockerHost sets a custom Docker socket path (overrides default Colima socket).

func (*ColimaBackend) SocketPath added in v1.3.0

func (b *ColimaBackend) SocketPath(ctx context.Context) string

SocketPath implements BackendSocketPath.

func (*ColimaBackend) Start

func (b *ColimaBackend) Start(ctx context.Context, envID string) error

func (*ColimaBackend) Stop

func (b *ColimaBackend) Stop(ctx context.Context, envID string) error

type ContainerSetupConfig added in v1.1.17

type ContainerSetupConfig struct {
	// StudioName is the name of the studio (used for config file paths)
	StudioName string
	// GPUWorkerURL is the connection URL to the GPU worker
	GPUWorkerURL string
	// HardwareVendor is the GPU vendor (nvidia, amd, hygon)
	HardwareVendor string
	// MountUserHome indicates whether to mount the user's home directory
	MountUserHome bool
	// SkipSSHMounts disables mounting SSH key files into the container
	SkipSSHMounts bool
	// SkipFileMounts disables mounting files into the container (directories only)
	SkipFileMounts bool
	// UserHomeContainerPath is the path to mount user home in container (default: /home/user/host)
	UserHomeContainerPath string
}

ContainerSetupConfig holds configuration for container GPU environment setup

type ContainerSetupResult added in v1.1.17

type ContainerSetupResult struct {
	// EnvVars are environment variables to set in the container
	EnvVars map[string]string
	// VolumeMounts are volumes to mount in the container
	VolumeMounts []VolumeMount
	// LibrariesDownloaded indicates if libraries were downloaded during setup
	LibrariesDownloaded bool
}

ContainerSetupResult holds the result of container setup

func SetupContainerGPUEnv added in v1.1.17

func SetupContainerGPUEnv(ctx context.Context, config *ContainerSetupConfig) (*ContainerSetupResult, error)

SetupContainerGPUEnv sets up the GPU environment for a container This performs the same setup as `ggo use` does for Linux: 1. Downloads GPU client libraries for Linux (using host CPU arch) 2. Sets up GPU environment (env vars, ld.so.preload, ld.so.conf.d) 3. Optionally mounts user home directory

type CreateOptions

type CreateOptions struct {
	Name           string            `json:"name"`
	Mode           Mode              `json:"mode"`
	Image          string            `json:"image"`
	GPUWorkerURL   string            `json:"gpu_worker_url,omitempty"`  // TENSOR_FUSION_OPERATOR_CONNECTION_INFO
	HardwareVendor string            `json:"hardware_vendor,omitempty"` // nvidia, amd, hygon
	SSHPublicKey   string            `json:"ssh_public_key,omitempty"`
	WorkDir        string            `json:"work_dir,omitempty"`
	Ports          []PortMapping     `json:"ports,omitempty"`
	Envs           map[string]string `json:"envs,omitempty"`
	Volumes        []VolumeMount     `json:"volumes,omitempty"`
	Resources      ResourceSpec      `json:"resources,omitempty"`
	Labels         map[string]string `json:"labels,omitempty"`
	// NoUserVolume disables automatic mounting of user's home directory
	NoUserVolume bool `json:"no_user_volume,omitempty"`
	// Command specifies the container startup command or supplements ENTRYPOINT args
	Command []string `json:"command,omitempty"`
	// Endpoint overrides the GPU worker endpoint URL
	Endpoint string `json:"endpoint,omitempty"`
	// Platform specifies the container image platform (e.g., linux/amd64, linux/arm64)
	// If empty, auto-detect from VM/host architecture
	Platform string `json:"platform,omitempty"`
}

CreateOptions contains options for creating an environment

type DockerBackend

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

DockerBackend implements the Backend interface using Docker

func NewDockerBackend

func NewDockerBackend() *DockerBackend

NewDockerBackend creates a new Docker backend

func NewDockerBackendWithHost

func NewDockerBackendWithHost(dockerHost string) *DockerBackend

NewDockerBackendWithHost creates a new Docker backend with custom host

func NewPodmanBackend

func NewPodmanBackend() *DockerBackend

NewPodmanBackend creates a new Podman backend (uses Docker interface)

func (*DockerBackend) Create

func (b *DockerBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)

func (*DockerBackend) Exec

func (b *DockerBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)

func (*DockerBackend) Get

func (b *DockerBackend) Get(ctx context.Context, idOrName string) (*Environment, error)

func (*DockerBackend) GetHostArch added in v1.1.18

func (b *DockerBackend) GetHostArch(ctx context.Context) string

GetHostArch returns the architecture of the Docker host Returns "amd64", "arm64", or empty string if detection fails

func (*DockerBackend) IsAvailable

func (b *DockerBackend) IsAvailable(ctx context.Context) bool

func (*DockerBackend) List

func (b *DockerBackend) List(ctx context.Context) ([]*Environment, error)

func (*DockerBackend) Logs

func (b *DockerBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)

func (*DockerBackend) Mode

func (b *DockerBackend) Mode() Mode

func (*DockerBackend) Name

func (b *DockerBackend) Name() string

func (*DockerBackend) Remove

func (b *DockerBackend) Remove(ctx context.Context, envID string) error

func (*DockerBackend) SocketPath added in v1.3.0

func (b *DockerBackend) SocketPath(ctx context.Context) string

SocketPath implements BackendSocketPath. Returns the effective Docker socket path.

func (*DockerBackend) Start

func (b *DockerBackend) Start(ctx context.Context, envID string) error

func (*DockerBackend) Stop

func (b *DockerBackend) Stop(ctx context.Context, envID string) error

type Environment

type Environment struct {
	ID            string            `json:"id"`
	Name          string            `json:"name"`
	Mode          Mode              `json:"mode"`
	Image         string            `json:"image"`
	Status        EnvironmentStatus `json:"status"`
	ConnectionURL string            `json:"connection_url,omitempty"`
	SSHHost       string            `json:"ssh_host,omitempty"`
	SSHPort       int               `json:"ssh_port,omitempty"`
	SSHUser       string            `json:"ssh_user,omitempty"`
	WorkDir       string            `json:"work_dir,omitempty"`
	GPUWorkerURL  string            `json:"gpu_worker_url,omitempty"`
	CreatedAt     time.Time         `json:"created_at"`
	Labels        map[string]string `json:"labels,omitempty"`
}

Environment represents a running studio environment

type EnvironmentStatus

type EnvironmentStatus string

EnvironmentStatus represents the status of an environment

const (
	StatusPending    EnvironmentStatus = "pending"
	StatusPulling    EnvironmentStatus = "pulling"
	StatusStarting   EnvironmentStatus = "starting"
	StatusRunning    EnvironmentStatus = "running"
	StatusStopped    EnvironmentStatus = "stopped"
	StatusError      EnvironmentStatus = "error"
	StatusTerminated EnvironmentStatus = "terminated"
	StatusDeleted    EnvironmentStatus = "deleted"
	StatusUnknown    EnvironmentStatus = "unknown"
)

type GPUEnvConfig added in v1.1.7

type GPUEnvConfig struct {
	Vendor        GPUVendor
	ConnectionURL string // TENSOR_FUSION_OPERATOR_CONNECTION_INFO value
	CachePath     string // Path to gpugo cache directory (for binaries like tensor-fusion-worker)
	LibsPath      string // Path to gpugo libs directory (for .so/.dll files, used in LD paths)
	LogPath       string // Path to logs directory
	StudioName    string // Name of the studio (for creating config files)
	IsContainer   bool   // Whether this is for a container (affects paths)
}

GPUEnvConfig holds configuration for GPU environment setup

type GPUEnvResult added in v1.1.7

type GPUEnvResult struct {
	EnvVars         map[string]string
	LDSoConfPath    string        // Host path to ld.so.conf file
	LDSoPreloadPath string        // Host path to ld.so.preload file
	VolumeMounts    []VolumeMount // Additional volume mounts needed
}

GPUEnvResult holds the result of GPU environment setup

func SetupGPUEnv added in v1.1.7

func SetupGPUEnv(paths *platform.Paths, config *GPUEnvConfig) (*GPUEnvResult, error)

SetupGPUEnv creates and configures GPU environment files

type GPUVendor added in v1.1.7

type GPUVendor string

GPUVendor represents supported GPU vendors

const (
	VendorNvidia  GPUVendor = "nvidia"
	VendorAMD     GPUVendor = "amd"
	VendorHygon   GPUVendor = "hygon"
	VendorUnknown GPUVendor = "unknown"
)

func ParseVendor added in v1.1.7

func ParseVendor(vendor string) GPUVendor

ParseVendor parses a vendor string to GPUVendor

type LibraryDownloader

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

LibraryDownloader handles downloading versioned GPU libraries from CDN

func NewLibraryDownloader

func NewLibraryDownloader(cdnURL, version string) *LibraryDownloader

NewLibraryDownloader creates a new library downloader

func (*LibraryDownloader) Download

func (d *LibraryDownloader) Download(lib LibraryInfo) (string, error)

Download downloads a library from the CDN

func (*LibraryDownloader) DownloadDefaultLibraries

func (d *LibraryDownloader) DownloadDefaultLibraries() ([]string, error)

DownloadDefaultLibraries downloads the default set of GPU libraries

func (*LibraryDownloader) DownloadURL

func (d *LibraryDownloader) DownloadURL(lib LibraryInfo) string

DownloadURL constructs the CDN download URL for a library

func (*LibraryDownloader) GetCacheDir

func (d *LibraryDownloader) GetCacheDir() string

GetCacheDir returns the cache directory path

func (*LibraryDownloader) SetCacheDir

func (d *LibraryDownloader) SetCacheDir(dir string)

SetCacheDir sets a custom cache directory

type LibraryInfo

type LibraryInfo struct {
	Name     string
	Version  string
	Arch     Architecture
	Checksum string // SHA256 checksum
}

LibraryInfo contains information about a library to download

type Manager

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

Manager manages AI studio environments across different backends

func NewManager

func NewManager() *Manager

NewManager creates a new studio manager

func (*Manager) AddSSHConfig

func (m *Manager) AddSSHConfig(env *Environment) error

AddSSHConfig adds an SSH config entry for an environment

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)

Create creates a new environment

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, idOrName string) (*Environment, error)

Get gets an environment by ID or name

func (*Manager) GetBackend

func (m *Manager) GetBackend(mode Mode) (Backend, error)

GetBackend returns a backend by mode

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]*Environment, error)

List lists all environments across all backends

func (*Manager) ListAvailableBackends

func (m *Manager) ListAvailableBackends(ctx context.Context) []Backend

ListAvailableBackends returns all available backends

func (*Manager) RegisterBackend

func (m *Manager) RegisterBackend(backend Backend)

RegisterBackend registers a backend

func (*Manager) Remove

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

Remove removes an environment

func (*Manager) RemoveAll added in v1.3.0

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

RemoveAll removes all known environments. When runtimes are offline, stale state entries are still cleaned up.

func (*Manager) RemoveSSHConfig

func (m *Manager) RemoveSSHConfig(envName string) error

RemoveSSHConfig removes an SSH config entry for an environment

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, idOrName string) error

Start starts an environment

func (*Manager) Stop

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

Stop stops an environment

type Mode

type Mode string

Mode represents the container/VM runtime mode

const (
	ModeWSL            Mode = "wsl"             // Windows Subsystem for Linux
	ModeColima         Mode = "colima"          // Colima (macOS/Linux)
	ModeAppleContainer Mode = "apple-container" // Apple Container (macOS)
	ModeDocker         Mode = "docker"          // Native Docker
	ModeKubernetes     Mode = "k8s"             // Kubernetes (kind, minikube, etc.)
	ModeAuto           Mode = "auto"            // Auto-detect best option
)

type PortMapping

type PortMapping struct {
	HostPort      int    `json:"host_port"`
	ContainerPort int    `json:"container_port"`
	Protocol      string `json:"protocol,omitempty"` // tcp, udp
}

PortMapping represents a port mapping

type ResourceSpec

type ResourceSpec struct {
	CPUs   float64 `json:"cpus,omitempty"`
	Memory string  `json:"memory,omitempty"` // e.g., "8Gi"
}

ResourceSpec represents resource limits

type SSHConfig

type SSHConfig struct {
	Host         string
	HostName     string
	User         string
	Port         int
	IdentityFile string
	ExtraOptions map[string]string
}

SSHConfig represents an SSH configuration entry

func (*SSHConfig) GenerateSSHConfigEntry

func (c *SSHConfig) GenerateSSHConfigEntry() string

GenerateSSHConfigEntry generates an SSH config entry string

type StudioImage

type StudioImage struct {
	Name        string            `json:"name"`
	Tag         string            `json:"tag"`
	Description string            `json:"description"`
	Features    []string          `json:"features"` // torch, cuda, ssh, jupyter, etc.
	Size        string            `json:"size"`
	Registry    string            `json:"registry"`
	Labels      map[string]string `json:"labels,omitempty"`
}

StudioImage represents a pre-configured AI development image

func DefaultImages

func DefaultImages() []StudioImage

DefaultImages returns the list of available studio images

type VolumeMount

type VolumeMount struct {
	HostPath      string `json:"host_path"`
	ContainerPath string `json:"container_path"`
	ReadOnly      bool   `json:"read_only,omitempty"`
}

VolumeMount represents a volume mount

func MergeVolumeMounts added in v1.1.17

func MergeVolumeMounts(setupVolumes, userVolumes []VolumeMount) []VolumeMount

MergeVolumeMounts merges user-provided volumes with setup result volumes If the same container path exists, user-provided volume takes precedence

type WSLBackend

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

WSLBackend implements the Backend interface using Windows Subsystem for Linux

func NewWSLBackend

func NewWSLBackend() *WSLBackend

NewWSLBackend creates a new WSL backend

func NewWSLBackendWithDistro

func NewWSLBackendWithDistro(distro string) *WSLBackend

NewWSLBackendWithDistro creates a new WSL backend with specific distro

func (*WSLBackend) Create

func (b *WSLBackend) Create(ctx context.Context, opts *CreateOptions) (*Environment, error)

func (*WSLBackend) EnsureSSHServer

func (b *WSLBackend) EnsureSSHServer(ctx context.Context, envID string) error

EnsureSSHServer ensures SSH server is running in the container

func (*WSLBackend) Exec

func (b *WSLBackend) Exec(ctx context.Context, envID string, cmd []string) ([]byte, error)

func (*WSLBackend) Get

func (b *WSLBackend) Get(ctx context.Context, idOrName string) (*Environment, error)

func (*WSLBackend) GetDistro

func (b *WSLBackend) GetDistro(ctx context.Context) (string, error)

GetDistro returns the configured or default WSL distribution

func (*WSLBackend) GetWSLIP

func (b *WSLBackend) GetWSLIP(ctx context.Context) (string, error)

GetWSLIP returns the IP address of the WSL instance

func (*WSLBackend) GetWSLStatus added in v1.1.7

func (b *WSLBackend) GetWSLStatus(ctx context.Context) *WSLStatus

GetWSLStatus checks the detailed status of WSL

func (*WSLBackend) IsAvailable

func (b *WSLBackend) IsAvailable(ctx context.Context) bool

func (*WSLBackend) List

func (b *WSLBackend) List(ctx context.Context) ([]*Environment, error)

func (*WSLBackend) Logs

func (b *WSLBackend) Logs(ctx context.Context, envID string, follow bool) (<-chan string, error)

func (*WSLBackend) Mode

func (b *WSLBackend) Mode() Mode

func (*WSLBackend) Name

func (b *WSLBackend) Name() string

func (*WSLBackend) Remove

func (b *WSLBackend) Remove(ctx context.Context, envID string) error

func (*WSLBackend) SetDistro

func (b *WSLBackend) SetDistro(distro string)

SetDistro sets the WSL distribution name

func (*WSLBackend) SocketPath added in v1.3.0

func (b *WSLBackend) SocketPath(ctx context.Context) string

SocketPath implements BackendSocketPath. Returns the Docker socket path inside the WSL distro.

func (*WSLBackend) Start

func (b *WSLBackend) Start(ctx context.Context, envID string) error

func (*WSLBackend) Stop

func (b *WSLBackend) Stop(ctx context.Context, envID string) error

type WSLStatus added in v1.1.7

type WSLStatus struct {
	WSLInstalled     bool
	HasDistribution  bool
	DistributionName string
	DockerInstalled  bool
	DockerRunning    bool
	ErrorMessage     string
}

WSLStatus represents the detailed status of WSL

func (*WSLStatus) GetInstallGuidance added in v1.1.7

func (s *WSLStatus) GetInstallGuidance() string

GetInstallGuidance returns installation guidance based on the current status

func (*WSLStatus) IsReady added in v1.1.7

func (s *WSLStatus) IsReady() bool

IsReady returns true if WSL is ready to run containers

Jump to

Keyboard shortcuts

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