Skip to content

Commit 372bc2a

Browse files
committed
Improve the limayaml and default.yaml syntax
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]>
1 parent 541eb2d commit 372bc2a

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

examples/default.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mounts:
5656
- location: "~"
5757
# Configure the mountPoint inside the guest.
5858
# 🟢 Builtin default: value of location
59-
mountPoint: null
59+
mountPoint: ""
6060
# CAUTION: `writable` SHOULD be false for the home directory.
6161
# Setting `writable` to true is possible, but untested and dangerous.
6262
# 🟢 Builtin default: false
@@ -254,11 +254,11 @@ containerd:
254254
# Setting of instructions is supported like this: "qemu64,+ssse3".
255255
cpuType:
256256
# 🟢 Builtin default: "cortex-a72" (or "host" when running on aarch64 host)
257-
aarch64: null
257+
aarch64: ""
258258
# 🟢 Builtin default: "cortex-a7" (or "host" when running on armv7l host)
259-
armv7l: null
259+
armv7l: ""
260260
# 🟢 Builtin default: "qemu64" (or "host,-pdpe1gb" when running on x86_64 host)
261-
x86_64: null
261+
x86_64: ""
262262

263263
rosetta:
264264
# Enable Rosetta for Linux (EXPERIMENTAL).

pkg/limayaml/limayaml.go

+47-47
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,41 @@ import (
77
)
88

99
type LimaYAML struct {
10-
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
11-
OS *OS `yaml:"os,omitempty" json:"os,omitempty"`
12-
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
10+
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty" jsonschema:"nullable"`
11+
OS *OS `yaml:"os,omitempty" json:"os,omitempty" jsonschema:"nullable"`
12+
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty" jsonschema:"nullable"`
1313
Images []Image `yaml:"images" json:"images"` // REQUIRED
1414
CPUType map[Arch]string `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
15-
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
16-
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
17-
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
18-
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty"`
15+
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty" jsonschema:"nullable"`
16+
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty" jsonschema:"nullable"` // go-units.RAMInBytes
17+
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty" jsonschema:"nullable"` // go-units.RAMInBytes
18+
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty" jsonschema:"nullable"` // commented out
1919
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
20-
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
21-
MountInotify *bool `yaml:"mountInotify,omitempty" json:"mountInotify,omitempty"`
20+
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty" jsonschema:"nullable"`
21+
MountInotify *bool `yaml:"mountInotify,omitempty" json:"mountInotify,omitempty" jsonschema:"nullable"`
2222
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
2323
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
2424
Audio Audio `yaml:"audio,omitempty" json:"audio,omitempty"`
2525
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
2626
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
27-
UpgradePackages *bool `yaml:"upgradePackages,omitempty" json:"upgradePackages,omitempty"`
27+
UpgradePackages *bool `yaml:"upgradePackages,omitempty" json:"upgradePackages,omitempty" jsonschema:"nullable"`
2828
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
29-
GuestInstallPrefix *string `yaml:"guestInstallPrefix,omitempty" json:"guestInstallPrefix,omitempty"`
29+
GuestInstallPrefix *string `yaml:"guestInstallPrefix,omitempty" json:"guestInstallPrefix,omitempty" jsonschema:"nullable"`
3030
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
3131
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
3232
CopyToHost []CopyToHost `yaml:"copyToHost,omitempty" json:"copyToHost,omitempty"`
3333
Message string `yaml:"message,omitempty" json:"message,omitempty"`
34-
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
34+
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty" jsonschema:"nullable"` // commented out
3535
// `network` was deprecated in Lima v0.7.0, removed in Lima v0.14.0. Use `networks` instead.
3636
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
3737
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
3838
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
3939
// `useHostResolver` was deprecated in Lima v0.8.1, removed in Lima v0.14.0. Use `hostResolver.enabled` instead.
40-
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
40+
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty" jsonschema:"nullable"`
4141
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
4242
Rosetta Rosetta `yaml:"rosetta,omitempty" json:"rosetta,omitempty"`
43-
Plain *bool `yaml:"plain,omitempty" json:"plain,omitempty"`
44-
TimeZone *string `yaml:"timezone,omitempty" json:"timezone,omitempty"`
43+
Plain *bool `yaml:"plain,omitempty" json:"plain,omitempty" jsonschema:"nullable"`
44+
TimeZone *string `yaml:"timezone,omitempty" json:"timezone,omitempty" jsonschema:"nullable"`
4545
}
4646

4747
type (
@@ -70,8 +70,8 @@ const (
7070
)
7171

7272
type Rosetta struct {
73-
Enabled *bool `yaml:"enabled" json:"enabled"`
74-
BinFmt *bool `yaml:"binfmt" json:"binfmt"`
73+
Enabled *bool `yaml:"enabled" json:"enabled" jsonschema:"nullable"`
74+
BinFmt *bool `yaml:"binfmt" json:"binfmt" jsonschema:"nullable"`
7575
}
7676

7777
type File struct {
@@ -106,7 +106,7 @@ type Disk struct {
106106
type Mount struct {
107107
Location string `yaml:"location" json:"location"` // REQUIRED
108108
MountPoint string `yaml:"mountPoint,omitempty" json:"mountPoint,omitempty"`
109-
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty"`
109+
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty" jsonschema:"nullable"`
110110
SSHFS SSHFS `yaml:"sshfs,omitempty" json:"sshfs,omitempty"`
111111
NineP NineP `yaml:"9p,omitempty" json:"9p,omitempty"`
112112
Virtiofs Virtiofs `yaml:"virtiofs,omitempty" json:"virtiofs,omitempty"`
@@ -120,16 +120,16 @@ const (
120120
)
121121

122122
type SSHFS struct {
123-
Cache *bool `yaml:"cache,omitempty" json:"cache,omitempty"`
124-
FollowSymlinks *bool `yaml:"followSymlinks,omitempty" json:"followSymlinks,omitempty"`
125-
SFTPDriver *SFTPDriver `yaml:"sftpDriver,omitempty" json:"sftpDriver,omitempty"`
123+
Cache *bool `yaml:"cache,omitempty" json:"cache,omitempty" jsonschema:"nullable"`
124+
FollowSymlinks *bool `yaml:"followSymlinks,omitempty" json:"followSymlinks,omitempty" jsonschema:"nullable"`
125+
SFTPDriver *SFTPDriver `yaml:"sftpDriver,omitempty" json:"sftpDriver,omitempty" jsonschema:"nullable"`
126126
}
127127

128128
type NineP struct {
129-
SecurityModel *string `yaml:"securityModel,omitempty" json:"securityModel,omitempty"`
130-
ProtocolVersion *string `yaml:"protocolVersion,omitempty" json:"protocolVersion,omitempty"`
131-
Msize *string `yaml:"msize,omitempty" json:"msize,omitempty"`
132-
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty"`
129+
SecurityModel *string `yaml:"securityModel,omitempty" json:"securityModel,omitempty" jsonschema:"nullable"`
130+
ProtocolVersion *string `yaml:"protocolVersion,omitempty" json:"protocolVersion,omitempty" jsonschema:"nullable"`
131+
Msize *string `yaml:"msize,omitempty" json:"msize,omitempty" jsonschema:"nullable"`
132+
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty" jsonschema:"nullable"`
133133
}
134134

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

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

149149
type Firmware struct {
150150
// LegacyBIOS disables UEFI if set.
151151
// LegacyBIOS is ignored for aarch64.
152-
LegacyBIOS *bool `yaml:"legacyBIOS,omitempty" json:"legacyBIOS,omitempty"`
152+
LegacyBIOS *bool `yaml:"legacyBIOS,omitempty" json:"legacyBIOS,omitempty" jsonschema:"nullable"`
153153

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

159159
type Audio struct {
160160
// Device is a QEMU audiodev string
161-
Device *string `yaml:"device,omitempty" json:"device,omitempty"`
161+
Device *string `yaml:"device,omitempty" json:"device,omitempty" jsonschema:"nullable"`
162162
}
163163

164164
type VNCOptions struct {
165-
Display *string `yaml:"display,omitempty" json:"display,omitempty"`
165+
Display *string `yaml:"display,omitempty" json:"display,omitempty" jsonschema:"nullable"`
166166
}
167167

168168
type Video struct {
169169
// Display is a QEMU display string
170-
Display *string `yaml:"display,omitempty" json:"display,omitempty"`
171-
VNC VNCOptions `yaml:"vnc" json:"vnc"`
170+
Display *string `yaml:"display,omitempty" json:"display,omitempty" jsonschema:"nullable"`
171+
VNC VNCOptions `yaml:"vnc,omitempty" json:"vnc,omitempty"`
172172
}
173173

174174
type ProvisionMode = string
@@ -181,14 +181,14 @@ const (
181181
)
182182

183183
type Provision struct {
184-
Mode ProvisionMode `yaml:"mode" json:"mode"` // default: "system"
184+
Mode ProvisionMode `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"default=system"`
185185
SkipDefaultDependencyResolution *bool `yaml:"skipDefaultDependencyResolution,omitempty" json:"skipDefaultDependencyResolution,omitempty"`
186186
Script string `yaml:"script" json:"script"`
187187
}
188188

189189
type Containerd struct {
190-
System *bool `yaml:"system,omitempty" json:"system,omitempty"` // default: false
191-
User *bool `yaml:"user,omitempty" json:"user,omitempty"` // default: true
190+
System *bool `yaml:"system,omitempty" json:"system,omitempty" jsonschema:"nullable"` // default: false
191+
User *bool `yaml:"user,omitempty" json:"user,omitempty" jsonschema:"nullable"` // default: true
192192
Archives []File `yaml:"archives,omitempty" json:"archives,omitempty"` // default: see defaultContainerdArchives
193193
}
194194

@@ -199,10 +199,10 @@ const (
199199
)
200200

201201
type Probe struct {
202-
Mode ProbeMode // default: "readiness"
203-
Description string
204-
Script string
205-
Hint string
202+
Mode ProbeMode `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"default=readiness"`
203+
Description string `yaml:"description,omitempty" json:"description,omitempty"`
204+
Script string `yaml:"script,omitempty" json:"script,omitempty"`
205+
Hint string `yaml:"hint,omitempty" json:"hint,omitempty"`
206206
}
207207

208208
type Proto = string
@@ -250,15 +250,15 @@ type Network struct {
250250
}
251251

252252
type HostResolver struct {
253-
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
254-
IPv6 *bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty"`
255-
Hosts map[string]string `yaml:"hosts,omitempty" json:"hosts,omitempty"`
253+
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty" jsonschema:"nullable"`
254+
IPv6 *bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty" jsonschema:"nullable"`
255+
Hosts map[string]string `yaml:"hosts,omitempty" json:"hosts,omitempty" jsonschema:"nullable"`
256256
}
257257

258258
type CACertificates struct {
259-
RemoveDefaults *bool `yaml:"removeDefaults,omitempty" json:"removeDefaults,omitempty"` // default: false
260-
Files []string `yaml:"files,omitempty" json:"files,omitempty"`
261-
Certs []string `yaml:"certs,omitempty" json:"certs,omitempty"`
259+
RemoveDefaults *bool `yaml:"removeDefaults,omitempty" json:"removeDefaults,omitempty" jsonschema:"nullable"` // default: false
260+
Files []string `yaml:"files,omitempty" json:"files,omitempty" jsonschema:"nullable"`
261+
Certs []string `yaml:"certs,omitempty" json:"certs,omitempty" jsonschema:"nullable"`
262262
}
263263

264264
// DEPRECATED types below

0 commit comments

Comments
 (0)