Skip to content

Commit 5fd962e

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 <anders.f.bjorklund@gmail.com>
1 parent 4545990 commit 5fd962e

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

examples/default.yaml

Lines changed: 1 addition & 1 deletion
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

pkg/limayaml/limayaml.go

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ 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
14-
CPUType CPUType `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"`
14+
CPUType CPUType `yaml:"cpuType,omitempty" json:"cpuType,omitempty" jsonschema:"nullable"`
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
Param map[string]string `yaml:"param,omitempty" json:"param,omitempty"`
3838
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
3939
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
4040
// `useHostResolver` was deprecated in Lima v0.8.1, removed in Lima v0.14.0. Use `hostResolver.enabled` instead.
41-
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
41+
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty" jsonschema:"nullable"`
4242
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
4343
Rosetta Rosetta `yaml:"rosetta,omitempty" json:"rosetta,omitempty"`
44-
Plain *bool `yaml:"plain,omitempty" json:"plain,omitempty"`
45-
TimeZone *string `yaml:"timezone,omitempty" json:"timezone,omitempty"`
44+
Plain *bool `yaml:"plain,omitempty" json:"plain,omitempty" jsonschema:"nullable"`
45+
TimeZone *string `yaml:"timezone,omitempty" json:"timezone,omitempty" jsonschema:"nullable"`
4646
}
4747

4848
type (
@@ -73,8 +73,8 @@ const (
7373
)
7474

7575
type Rosetta struct {
76-
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
77-
BinFmt *bool `yaml:"binfmt,omitempty" json:"binfmt,omitempty"`
76+
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty" jsonschema:"nullable"`
77+
BinFmt *bool `yaml:"binfmt,omitempty" json:"binfmt,omitempty" jsonschema:"nullable"`
7878
}
7979

8080
type File struct {
@@ -109,7 +109,7 @@ type Disk struct {
109109
type Mount struct {
110110
Location string `yaml:"location" json:"location"` // REQUIRED
111111
MountPoint string `yaml:"mountPoint,omitempty" json:"mountPoint,omitempty"`
112-
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty"`
112+
Writable *bool `yaml:"writable,omitempty" json:"writable,omitempty" jsonschema:"nullable"`
113113
SSHFS SSHFS `yaml:"sshfs,omitempty" json:"sshfs,omitempty"`
114114
NineP NineP `yaml:"9p,omitempty" json:"9p,omitempty"`
115115
Virtiofs Virtiofs `yaml:"virtiofs,omitempty" json:"virtiofs,omitempty"`
@@ -123,36 +123,36 @@ const (
123123
)
124124

125125
type SSHFS struct {
126-
Cache *bool `yaml:"cache,omitempty" json:"cache,omitempty"`
127-
FollowSymlinks *bool `yaml:"followSymlinks,omitempty" json:"followSymlinks,omitempty"`
128-
SFTPDriver *SFTPDriver `yaml:"sftpDriver,omitempty" json:"sftpDriver,omitempty"`
126+
Cache *bool `yaml:"cache,omitempty" json:"cache,omitempty" jsonschema:"nullable"`
127+
FollowSymlinks *bool `yaml:"followSymlinks,omitempty" json:"followSymlinks,omitempty" jsonschema:"nullable"`
128+
SFTPDriver *SFTPDriver `yaml:"sftpDriver,omitempty" json:"sftpDriver,omitempty" jsonschema:"nullable"`
129129
}
130130

131131
type NineP struct {
132-
SecurityModel *string `yaml:"securityModel,omitempty" json:"securityModel,omitempty"`
133-
ProtocolVersion *string `yaml:"protocolVersion,omitempty" json:"protocolVersion,omitempty"`
134-
Msize *string `yaml:"msize,omitempty" json:"msize,omitempty"`
135-
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty"`
132+
SecurityModel *string `yaml:"securityModel,omitempty" json:"securityModel,omitempty" jsonschema:"nullable"`
133+
ProtocolVersion *string `yaml:"protocolVersion,omitempty" json:"protocolVersion,omitempty" jsonschema:"nullable"`
134+
Msize *string `yaml:"msize,omitempty" json:"msize,omitempty" jsonschema:"nullable"`
135+
Cache *string `yaml:"cache,omitempty" json:"cache,omitempty" jsonschema:"nullable"`
136136
}
137137

138138
type Virtiofs struct {
139139
QueueSize *int `yaml:"queueSize,omitempty" json:"queueSize,omitempty"`
140140
}
141141

142142
type SSH struct {
143-
LocalPort *int `yaml:"localPort,omitempty" json:"localPort,omitempty"`
143+
LocalPort *int `yaml:"localPort,omitempty" json:"localPort,omitempty" jsonschema:"nullable"`
144144

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

152152
type Firmware struct {
153153
// LegacyBIOS disables UEFI if set.
154154
// LegacyBIOS is ignored for aarch64.
155-
LegacyBIOS *bool `yaml:"legacyBIOS,omitempty" json:"legacyBIOS,omitempty"`
155+
LegacyBIOS *bool `yaml:"legacyBIOS,omitempty" json:"legacyBIOS,omitempty" jsonschema:"nullable"`
156156

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

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

167167
type VNCOptions struct {
168-
Display *string `yaml:"display,omitempty" json:"display,omitempty"`
168+
Display *string `yaml:"display,omitempty" json:"display,omitempty" jsonschema:"nullable"`
169169
}
170170

171171
type Video struct {
172172
// Display is a QEMU display string
173-
Display *string `yaml:"display,omitempty" json:"display,omitempty"`
174-
VNC VNCOptions `yaml:"vnc" json:"vnc"`
173+
Display *string `yaml:"display,omitempty" json:"display,omitempty" jsonschema:"nullable"`
174+
VNC VNCOptions `yaml:"vnc,omitempty" json:"vnc,omitempty"`
175175
}
176176

177177
type ProvisionMode = string
@@ -185,16 +185,16 @@ const (
185185
)
186186

187187
type Provision struct {
188-
Mode ProvisionMode `yaml:"mode" json:"mode"` // default: "system"
188+
Mode ProvisionMode `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"default=system"`
189189
SkipDefaultDependencyResolution *bool `yaml:"skipDefaultDependencyResolution,omitempty" json:"skipDefaultDependencyResolution,omitempty"`
190190
Script string `yaml:"script" json:"script"`
191191
Playbook string `yaml:"playbook,omitempty" json:"playbook,omitempty"`
192192
}
193193

194194
type Containerd struct {
195-
System *bool `yaml:"system,omitempty" json:"system,omitempty"` // default: false
196-
User *bool `yaml:"user,omitempty" json:"user,omitempty"` // default: true
197-
Archives []File `yaml:"archives,omitempty" json:"archives,omitempty"` // default: see defaultContainerdArchives
195+
System *bool `yaml:"system,omitempty" json:"system,omitempty" jsonschema:"nullable"` // default: false
196+
User *bool `yaml:"user,omitempty" json:"user,omitempty" jsonschema:"nullable"` // default: true
197+
Archives []File `yaml:"archives,omitempty" json:"archives,omitempty"` // default: see defaultContainerdArchives
198198
}
199199

200200
type ProbeMode = string
@@ -204,10 +204,10 @@ const (
204204
)
205205

206206
type Probe struct {
207-
Mode ProbeMode // default: "readiness"
208-
Description string
209-
Script string
210-
Hint string
207+
Mode ProbeMode `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"default=readiness"`
208+
Description string `yaml:"description,omitempty" json:"description,omitempty"`
209+
Script string `yaml:"script,omitempty" json:"script,omitempty"`
210+
Hint string `yaml:"hint,omitempty" json:"hint,omitempty"`
211211
}
212212

213213
type Proto = string
@@ -250,13 +250,13 @@ 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
}

0 commit comments

Comments
 (0)