Skip to content

Commit

Permalink
Improve the limayaml and default.yaml syntax
Browse files Browse the repository at this point in the history
Use empty strings for strings and document all the fields

Allow null for pointers and maps with commented out keys

Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed May 1, 2024
1 parent 541eb2d commit a177cd8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions examples/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mounts:
- location: "~"
# Configure the mountPoint inside the guest.
# 🟢 Builtin default: value of location
mountPoint: null
mountPoint: ""
# CAUTION: `writable` SHOULD be false for the home directory.
# Setting `writable` to true is possible, but untested and dangerous.
# 🟢 Builtin default: false
Expand Down Expand Up @@ -254,11 +254,11 @@ containerd:
# Setting of instructions is supported like this: "qemu64,+ssse3".
cpuType:
# 🟢 Builtin default: "cortex-a72" (or "host" when running on aarch64 host)
aarch64: null
aarch64: ""
# 🟢 Builtin default: "cortex-a7" (or "host" when running on armv7l host)
armv7l: null
armv7l: ""
# 🟢 Builtin default: "qemu64" (or "host,-pdpe1gb" when running on x86_64 host)
x86_64: null
x86_64: ""

rosetta:
# Enable Rosetta for Linux (EXPERIMENTAL).
Expand Down
96 changes: 48 additions & 48 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@ import (
)

type LimaYAML struct {
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
OS *OS `yaml:"os,omitempty" json:"os,omitempty"`
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty" jsonschema:"nullable"`
OS *OS `yaml:"os,omitempty" json:"os,omitempty" jsonschema:"nullable"`
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty" jsonschema:"nullable"`
Images []Image `yaml:"images" json:"images"` // REQUIRED
CPUType map[Arch]string `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty"`
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty" jsonschema:"nullable"`
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty" jsonschema:"nullable"` // go-units.RAMInBytes
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty" jsonschema:"nullable"` // go-units.RAMInBytes
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty" jsonschema:"nullable"` // commented out
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
MountInotify *bool `yaml:"mountInotify,omitempty" json:"mountInotify,omitempty"`
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty" jsonschema:"nullable"`
MountInotify *bool `yaml:"mountInotify,omitempty" json:"mountInotify,omitempty" jsonschema:"nullable"`
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
Audio Audio `yaml:"audio,omitempty" json:"audio,omitempty"`
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
UpgradePackages *bool `yaml:"upgradePackages,omitempty" json:"upgradePackages,omitempty"`
UpgradePackages *bool `yaml:"upgradePackages,omitempty" json:"upgradePackages,omitempty" jsonschema:"nullable"`
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
GuestInstallPrefix *string `yaml:"guestInstallPrefix,omitempty" json:"guestInstallPrefix,omitempty"`
GuestInstallPrefix *string `yaml:"guestInstallPrefix,omitempty" json:"guestInstallPrefix,omitempty" jsonschema:"nullable"`
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
CopyToHost []CopyToHost `yaml:"copyToHost,omitempty" json:"copyToHost,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty" jsonschema:"nullable"` // commented out
// `network` was deprecated in Lima v0.7.0, removed in Lima v0.14.0. Use `networks` instead.
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
// `useHostResolver` was deprecated in Lima v0.8.1, removed in Lima v0.14.0. Use `hostResolver.enabled` instead.
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty" jsonschema:"nullable"`
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
Rosetta Rosetta `yaml:"rosetta,omitempty" json:"rosetta,omitempty"`
Plain *bool `yaml:"plain,omitempty" json:"plain,omitempty"`
TimeZone *string `yaml:"timezone,omitempty" json:"timezone,omitempty"`
Plain *bool `yaml:"plain,omitempty" json:"plain,omitempty" jsonschema:"nullable"`
TimeZone *string `yaml:"timezone,omitempty" json:"timezone,omitempty" jsonschema:"nullable"`
}

type (
Expand Down Expand Up @@ -70,8 +70,8 @@ const (
)

type Rosetta struct {
Enabled *bool `yaml:"enabled" json:"enabled"`
BinFmt *bool `yaml:"binfmt" json:"binfmt"`
Enabled *bool `yaml:"enabled" json:"enabled" jsonschema:"nullable"`
BinFmt *bool `yaml:"binfmt" json:"binfmt" jsonschema:"nullable"`
}

type File struct {
Expand Down Expand Up @@ -106,7 +106,7 @@ type Disk struct {
type Mount struct {
Location string `yaml:"location" json:"location"` // REQUIRED
MountPoint string `yaml:"mountPoint,omitempty" json:"mountPoint,omitempty"`
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty"`
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty" jsonschema:"nullable"`
SSHFS SSHFS `yaml:"sshfs,omitempty" json:"sshfs,omitempty"`
NineP NineP `yaml:"9p,omitempty" json:"9p,omitempty"`
Virtiofs Virtiofs `yaml:"virtiofs,omitempty" json:"virtiofs,omitempty"`
Expand All @@ -120,16 +120,16 @@ const (
)

type SSHFS struct {
Cache *bool `yaml:"cache,omitempty" json:"cache,omitempty"`
FollowSymlinks *bool `yaml:"followSymlinks,omitempty" json:"followSymlinks,omitempty"`
SFTPDriver *SFTPDriver `yaml:"sftpDriver,omitempty" json:"sftpDriver,omitempty"`
Cache *bool `yaml:"cache,omitempty" json:"cache,omitempty" jsonschema:"nullable"`
FollowSymlinks *bool `yaml:"followSymlinks,omitempty" json:"followSymlinks,omitempty" jsonschema:"nullable"`
SFTPDriver *SFTPDriver `yaml:"sftpDriver,omitempty" json:"sftpDriver,omitempty" jsonschema:"nullable"`
}

type NineP struct {
SecurityModel *string `yaml:"securityModel,omitempty" json:"securityModel,omitempty"`
ProtocolVersion *string `yaml:"protocolVersion,omitempty" json:"protocolVersion,omitempty"`
Msize *string `yaml:"msize,omitempty" json:"msize,omitempty"`
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty"`
SecurityModel *string `yaml:"securityModel,omitempty" json:"securityModel,omitempty" jsonschema:"nullable"`
ProtocolVersion *string `yaml:"protocolVersion,omitempty" json:"protocolVersion,omitempty" jsonschema:"nullable"`
Msize *string `yaml:"msize,omitempty" json:"msize,omitempty" jsonschema:"nullable"`
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty" jsonschema:"nullable"`
}

type Virtiofs struct {
Expand All @@ -140,16 +140,16 @@ type SSH struct {
LocalPort *int `yaml:"localPort,omitempty" json:"localPort,omitempty"`

// LoadDotSSHPubKeys loads ~/.ssh/*.pub in addition to $LIMA_HOME/_config/user.pub .
LoadDotSSHPubKeys *bool `yaml:"loadDotSSHPubKeys,omitempty" json:"loadDotSSHPubKeys,omitempty"` // default: true
ForwardAgent *bool `yaml:"forwardAgent,omitempty" json:"forwardAgent,omitempty"` // default: false
ForwardX11 *bool `yaml:"forwardX11,omitempty" json:"forwardX11,omitempty"` // default: false
ForwardX11Trusted *bool `yaml:"forwardX11Trusted,omitempty" json:"forwardX11Trusted,omitempty"` // default: false
LoadDotSSHPubKeys *bool `yaml:"loadDotSSHPubKeys,omitempty" json:"loadDotSSHPubKeys,omitempty" jsonschema:"nullable"` // default: true
ForwardAgent *bool `yaml:"forwardAgent,omitempty" json:"forwardAgent,omitempty" jsonschema:"nullable"` // default: false
ForwardX11 *bool `yaml:"forwardX11,omitempty" json:"forwardX11,omitempty" jsonschema:"nullable"` // default: false
ForwardX11Trusted *bool `yaml:"forwardX11Trusted,omitempty" json:"forwardX11Trusted,omitempty" jsonschema:"nullable"` // default: false
}

type Firmware struct {
// LegacyBIOS disables UEFI if set.
// LegacyBIOS is ignored for aarch64.
LegacyBIOS *bool `yaml:"legacyBIOS,omitempty" json:"legacyBIOS,omitempty"`
LegacyBIOS *bool `yaml:"legacyBIOS,omitempty" json:"legacyBIOS,omitempty" jsonschema:"nullable"`

// Images specify UEFI images (edk2-aarch64-code.fd.gz).
// Defaults to built-in UEFI.
Expand All @@ -158,17 +158,17 @@ type Firmware struct {

type Audio struct {
// Device is a QEMU audiodev string
Device *string `yaml:"device,omitempty" json:"device,omitempty"`
Device *string `yaml:"device,omitempty" json:"device,omitempty" jsonschema:"nullable"`
}

type VNCOptions struct {
Display *string `yaml:"display,omitempty" json:"display,omitempty"`
Display *string `yaml:"display,omitempty" json:"display,omitempty" jsonschema:"nullable"`
}

type Video struct {
// Display is a QEMU display string
Display *string `yaml:"display,omitempty" json:"display,omitempty"`
VNC VNCOptions `yaml:"vnc" json:"vnc"`
Display *string `yaml:"display,omitempty" json:"display,omitempty" jsonschema:"nullable"`
VNC VNCOptions `yaml:"vnc,omitempty" json:"vnc,omitempty"`
}

type ProvisionMode = string
Expand All @@ -181,15 +181,15 @@ const (
)

type Provision struct {
Mode ProvisionMode `yaml:"mode" json:"mode"` // default: "system"
Mode ProvisionMode `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"default=system"`
SkipDefaultDependencyResolution *bool `yaml:"skipDefaultDependencyResolution,omitempty" json:"skipDefaultDependencyResolution,omitempty"`
Script string `yaml:"script" json:"script"`
}

type Containerd struct {
System *bool `yaml:"system,omitempty" json:"system,omitempty"` // default: false
User *bool `yaml:"user,omitempty" json:"user,omitempty"` // default: true
Archives []File `yaml:"archives,omitempty" json:"archives,omitempty"` // default: see defaultContainerdArchives
System *bool `yaml:"system,omitempty" json:"system,omitempty" jsonschema:"nullable"` // default: false
User *bool `yaml:"user,omitempty" json:"user,omitempty" jsonschema:"nullable"` // default: true
Archives []File `yaml:"archives,omitempty" json:"archives,omitempty"` // default: see defaultContainerdArchives
}

type ProbeMode = string
Expand All @@ -199,10 +199,10 @@ const (
)

type Probe struct {
Mode ProbeMode // default: "readiness"
Description string
Script string
Hint string
Mode ProbeMode `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"default=readiness"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Script string `yaml:"script,omitempty" json:"script,omitempty"`
Hint string `yaml:"hint,omitempty" json:"hint,omitempty"`
}

type Proto = string
Expand Down Expand Up @@ -250,15 +250,15 @@ type Network struct {
}

type HostResolver struct {
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
IPv6 *bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty"`
Hosts map[string]string `yaml:"hosts,omitempty" json:"hosts,omitempty"`
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty" jsonschema:"nullable"`
IPv6 *bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty" jsonschema:"nullable"`
Hosts map[string]string `yaml:"hosts,omitempty" json:"hosts,omitempty" jsonschema:"nullable"`
}

type CACertificates struct {
RemoveDefaults *bool `yaml:"removeDefaults,omitempty" json:"removeDefaults,omitempty"` // default: false
Files []string `yaml:"files,omitempty" json:"files,omitempty"`
Certs []string `yaml:"certs,omitempty" json:"certs,omitempty"`
RemoveDefaults *bool `yaml:"removeDefaults,omitempty" json:"removeDefaults,omitempty" jsonschema:"nullable"` // default: false
Files []string `yaml:"files,omitempty" json:"files,omitempty" jsonschema:"nullable"`
Certs []string `yaml:"certs,omitempty" json:"certs,omitempty" jsonschema:"nullable"`
}

// DEPRECATED types below
Expand Down

0 comments on commit a177cd8

Please sign in to comment.