lima

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package lima renders and validates the Lima template for the managed VM.

Index

Constants

View Source
const (
	DefaultMemoryMiB        = 3072
	DefaultCPUs             = 2
	DefaultDiskGiB          = 30
	DefaultMemoryMinMiB     = 2048
	DefaultMemoryMaxPercent = 50
	DefaultCPUMin           = 1
	DefaultDiskMinGiB       = 10
	DefaultDiskMaxGiB       = 1024
	DefaultDashboardGuest   = 8080
	DefaultIngressGuest     = 80
)

Defaults block (ADR 070 table). Nothing else in this package holds a limit.

View Source
const (

	// ImageSHAEnv overrides the digest of the image for the chosen arch. TESTING
	// only: production code must not set it.
	ImageSHAEnv = "APP_VM_IMAGE_SHA256"
)

Pinned Ubuntu 26.04 LTS cloud images. Digests are the publisher's SHA-256; a bump ships with a real-Mac isolation check.

Variables

This section is empty.

Functions

func CheckHome

func CheckHome(dir string) error

CheckHome refuses a Lima home that carries default.yaml or override.yaml: Lima merges them into every instance and override wins, so they could add mounts, wildcard forwards or agent forwarding. Call it before create and start.

func ImageOverrideFromEnv

func ImageOverrideFromEnv() string

ImageOverrideFromEnv reads APP_VM_IMAGE_SHA256 for RenderOptions. Testing only.

func Render

func Render(s Settings, l Limits, ro RenderOptions) ([]byte, error)

Render validates s against l and returns the Lima YAML. Shares need Lima's non-plain mode (plain ignores mounts), so a catch-all ignore rule then keeps guest agent auto forwarding off.

Types

type Image

type Image struct {
	Location string `yaml:"location"`
	Arch     string `yaml:"arch"`
	Digest   string `yaml:"digest"`
}

Image is one pinned guest image entry.

func Images

func Images(arch, override string) ([]Image, error)

Images returns the pinned images, applying the testing override to arch.

type Limits

type Limits struct {
	MemoryMinMiB int
	MemoryMaxMiB int
	CPUMin       int
	CPUMax       int
	DiskMinGiB   int
	DiskMaxGiB   int
	HomeDir      string
	DataDir      string
}

Limits bounds Settings. HomeDir and DataDir guard the share check.

func DefaultLimits

func DefaultLimits(hostMemoryMiB, hostCPUs, maxPercent int, homeDir, dataDir string) Limits

DefaultLimits derives limits from the host. maxPercent comes from APP_VM_MEMORY_MAX_PERCENT and falls back to the ADR default when zero.

type RenderOptions

type RenderOptions struct {
	// Arch is "aarch64" or "x86_64". Empty means aarch64.
	Arch string
	// ImageSHA256Override replaces the pinned digest for Arch. Testing only.
	ImageSHA256Override string
}

RenderOptions carries caller choices that are not VM settings.

type Settings

type Settings struct {
	MemoryMiB          int
	CPUs               int
	DiskGiB            int
	DashboardPort      int
	IngressPort        int
	DashboardGuestPort int
	IngressGuestPort   int
	Shares             []Share
	Sidecar            guest.Sidecar
	Guest              guest.Options
}

Settings is everything the template needs. Ports are host loopback ports.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the ADR defaults with unset (zero) host ports.

func (Settings) Validate

func (s Settings) Validate(l Limits) error

Validate checks settings against limits. The first failure is returned.

type Share

type Share struct {
	HostPath  string
	GuestPath string // Defaults to /mnt/shares/<base name>.
}

Share is one explicit host folder exposed to the guest. It is always read-only.

Jump to

Keyboard shortcuts

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