Skip to content

Commit c13580b

Browse files
committed
pkg/limayaml: remove deprecated network and useHostResolver
- `network`: deprecated in Lima v0.7.0 (Oct 2021), in favor of `networks`: 07e6823 - `useHostResolver`: deprecated in Lima v0.8.1 (Jan 2022), in favor of `hostResolver.enabled`: eaeee31 The deprecated support for VDE is not removed in this commit. Signed-off-by: Akihiro Suda <[email protected]>
1 parent 3c9eb1b commit c13580b

File tree

4 files changed

+26
-68
lines changed

4 files changed

+26
-68
lines changed

pkg/limayaml/defaults.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,6 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
309309
// After defaults processing the singular HostPort and GuestPort values should not be used again.
310310
}
311311

312-
// If both `useHostResolved` and `HostResolver.Enabled` are defined in the same config,
313-
// then the deprecated `useHostResolved` setting is silently ignored.
314-
if y.HostResolver.Enabled == nil {
315-
y.HostResolver.Enabled = y.UseHostResolver
316-
}
317-
if d.HostResolver.Enabled == nil {
318-
d.HostResolver.Enabled = d.UseHostResolver
319-
}
320-
if o.HostResolver.Enabled == nil {
321-
o.HostResolver.Enabled = o.UseHostResolver
322-
}
323-
324312
if y.HostResolver.Enabled == nil {
325313
y.HostResolver.Enabled = d.HostResolver.Enabled
326314
}
@@ -351,19 +339,6 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
351339
y.PropagateProxyEnv = pointer.Bool(true)
352340
}
353341

354-
if len(y.Network.VDEDeprecated) > 0 && len(y.Networks) == 0 {
355-
for _, vde := range y.Network.VDEDeprecated {
356-
network := Network{
357-
Interface: vde.Name,
358-
MACAddress: vde.MACAddress,
359-
SwitchPortDeprecated: vde.SwitchPort,
360-
VNLDeprecated: vde.VNL,
361-
}
362-
y.Networks = append(y.Networks, network)
363-
}
364-
y.Network.migrated = true
365-
}
366-
367342
networks := make([]Network, 0, len(d.Networks)+len(y.Networks)+len(o.Networks))
368343
iface := make(map[string]int)
369344
for _, nw := range append(append(d.Networks, y.Networks...), o.Networks...) {

pkg/limayaml/defaults_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ func TestFillDefault(t *testing.T) {
2222
var d, y, o LimaYAML
2323

2424
opts := []cmp.Option{
25-
// Ignore internal NetworkDeprecated.migrated field
26-
cmpopts.IgnoreUnexported(NetworkDeprecated{}),
2725
// Consider nil slices and empty slices to be identical
2826
cmpopts.EquateEmpty(),
2927
}

pkg/limayaml/limayaml.go

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@ import (
77
)
88

99
type LimaYAML struct {
10-
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
11-
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
12-
Images []Image `yaml:"images" json:"images"` // REQUIRED
13-
CPUType map[Arch]string `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
14-
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
15-
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
16-
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
17-
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty"`
18-
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
19-
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
20-
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
21-
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
22-
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
23-
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
24-
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
25-
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
26-
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
27-
Message string `yaml:"message,omitempty" json:"message,omitempty"`
28-
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
29-
Network NetworkDeprecated `yaml:"network,omitempty" json:"network,omitempty"` // DEPRECATED, use `networks` instead
30-
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
31-
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
32-
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
33-
UseHostResolver *bool `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"` // DEPRECATED, use `HostResolver.Enabled` instead
34-
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
35-
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
10+
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
11+
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
12+
Images []Image `yaml:"images" json:"images"` // REQUIRED
13+
CPUType map[Arch]string `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
14+
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
15+
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
16+
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
17+
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty"`
18+
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
19+
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
20+
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
21+
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
22+
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
23+
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
24+
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
25+
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
26+
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
27+
Message string `yaml:"message,omitempty" json:"message,omitempty"`
28+
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
29+
// `network` was deprecated in Lima v0.7.0, removed in Lima v0.14.0. Use `networks` instead.
30+
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
31+
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
32+
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
33+
// `useHostResolver` was deprecated in Lima v0.8.1, removed in Lima v0.14.0. Use `hostResolver.enabled` instead.
34+
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
35+
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
3636
}
3737

3838
type Arch = string
@@ -204,12 +204,6 @@ type CACertificates struct {
204204
// Types have been renamed to turn all references to the old names into compiler errors,
205205
// and to avoid accidental usage in new code.
206206

207-
type NetworkDeprecated struct {
208-
VDEDeprecated []VDEDeprecated `yaml:"vde,omitempty" json:"vde,omitempty"`
209-
// migrate will be true when `network.VDE` has been copied to `networks` by FillDefaults()
210-
migrated bool
211-
}
212-
213207
type VDEDeprecated struct {
214208
VNL string `yaml:"vnl,omitempty" json:"vnl,omitempty"`
215209
SwitchPort uint16 `yaml:"switchPort,omitempty" json:"switchPort,omitempty"` // VDE Switch port, not TCP/UDP port

pkg/limayaml/validate.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,6 @@ func Validate(y LimaYAML, warn bool) error {
261261
}
262262

263263
func validateNetwork(y LimaYAML, warn bool) error {
264-
if len(y.Network.VDEDeprecated) > 0 {
265-
if y.Network.migrated {
266-
if warn {
267-
logrus.Warnf("field `network.VDE` is deprecated; please use `networks` instead")
268-
}
269-
} else {
270-
return fmt.Errorf("you cannot use deprecated field `network.VDE` together with replacement field `networks`")
271-
}
272-
}
273264
interfaceName := make(map[string]int)
274265
for i, nw := range y.Networks {
275266
field := fmt.Sprintf("networks[%d]", i)

0 commit comments

Comments
 (0)