Skip to content

Commit

Permalink
Merge pull request #1186 from AkihiroSuda/remove-deprecated-network-a…
Browse files Browse the repository at this point in the history
…nd-hostresolver

pkg/limayaml: remove deprecated `network` and `useHostResolver`
  • Loading branch information
jandubois authored Nov 21, 2022
2 parents a307678 + c13580b commit fd55971
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 68 deletions.
25 changes: 0 additions & 25 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,18 +309,6 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
// After defaults processing the singular HostPort and GuestPort values should not be used again.
}

// If both `useHostResolved` and `HostResolver.Enabled` are defined in the same config,
// then the deprecated `useHostResolved` setting is silently ignored.
if y.HostResolver.Enabled == nil {
y.HostResolver.Enabled = y.UseHostResolver
}
if d.HostResolver.Enabled == nil {
d.HostResolver.Enabled = d.UseHostResolver
}
if o.HostResolver.Enabled == nil {
o.HostResolver.Enabled = o.UseHostResolver
}

if y.HostResolver.Enabled == nil {
y.HostResolver.Enabled = d.HostResolver.Enabled
}
Expand Down Expand Up @@ -351,19 +339,6 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
y.PropagateProxyEnv = pointer.Bool(true)
}

if len(y.Network.VDEDeprecated) > 0 && len(y.Networks) == 0 {
for _, vde := range y.Network.VDEDeprecated {
network := Network{
Interface: vde.Name,
MACAddress: vde.MACAddress,
SwitchPortDeprecated: vde.SwitchPort,
VNLDeprecated: vde.VNL,
}
y.Networks = append(y.Networks, network)
}
y.Network.migrated = true
}

networks := make([]Network, 0, len(d.Networks)+len(y.Networks)+len(o.Networks))
iface := make(map[string]int)
for _, nw := range append(append(d.Networks, y.Networks...), o.Networks...) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/limayaml/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ func TestFillDefault(t *testing.T) {
var d, y, o LimaYAML

opts := []cmp.Option{
// Ignore internal NetworkDeprecated.migrated field
cmpopts.IgnoreUnexported(NetworkDeprecated{}),
// Consider nil slices and empty slices to be identical
cmpopts.EquateEmpty(),
}
Expand Down
58 changes: 26 additions & 32 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ import (
)

type LimaYAML struct {
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
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"`
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
Network NetworkDeprecated `yaml:"network,omitempty" json:"network,omitempty"` // DEPRECATED, 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 *bool `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"` // DEPRECATED, use `HostResolver.Enabled` instead
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
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"`
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
// `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"`
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
}

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

type NetworkDeprecated struct {
VDEDeprecated []VDEDeprecated `yaml:"vde,omitempty" json:"vde,omitempty"`
// migrate will be true when `network.VDE` has been copied to `networks` by FillDefaults()
migrated bool
}

type VDEDeprecated struct {
VNL string `yaml:"vnl,omitempty" json:"vnl,omitempty"`
SwitchPort uint16 `yaml:"switchPort,omitempty" json:"switchPort,omitempty"` // VDE Switch port, not TCP/UDP port
Expand Down
9 changes: 0 additions & 9 deletions pkg/limayaml/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,6 @@ func Validate(y LimaYAML, warn bool) error {
}

func validateNetwork(y LimaYAML, warn bool) error {
if len(y.Network.VDEDeprecated) > 0 {
if y.Network.migrated {
if warn {
logrus.Warnf("field `network.VDE` is deprecated; please use `networks` instead")
}
} else {
return fmt.Errorf("you cannot use deprecated field `network.VDE` together with replacement field `networks`")
}
}
interfaceName := make(map[string]int)
for i, nw := range y.Networks {
field := fmt.Sprintf("networks[%d]", i)
Expand Down

0 comments on commit fd55971

Please sign in to comment.