From 2ea9707585f398d4b5790d9de40a64dd7200fdec Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Tue, 15 Oct 2024 19:43:23 +0200 Subject: [PATCH] fix: allow some netplan values to be string or int Netplan 0.107 introduced changes where some values that we parsed as integers, were explicitly rendered as strings. We already had a type, InString to handle this, so it becomes trivial to swap the concerned ints to IntString. --- network/netplan/netplan.go | 6 +++--- network/netplan/netplan_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/network/netplan/netplan.go b/network/netplan/netplan.go index 480938ca02be..5d7d4087ebc1 100644 --- a/network/netplan/netplan.go +++ b/network/netplan/netplan.go @@ -194,7 +194,7 @@ func (i IntString) MarshalYAML() (interface{}, error) { type BondParameters struct { Mode IntString `yaml:"mode,omitempty"` LACPRate IntString `yaml:"lacp-rate,omitempty"` - MIIMonitorInterval *int `yaml:"mii-monitor-interval,omitempty"` + MIIMonitorInterval IntString `yaml:"mii-monitor-interval,omitempty"` MinLinks *int `yaml:"min-links,omitempty"` TransmitHashPolicy string `yaml:"transmit-hash-policy,omitempty"` ADSelect IntString `yaml:"ad-select,omitempty"` @@ -203,8 +203,8 @@ type BondParameters struct { ARPIPTargets []string `yaml:"arp-ip-targets,omitempty"` ARPValidate IntString `yaml:"arp-validate,omitempty"` ARPAllTargets IntString `yaml:"arp-all-targets,omitempty"` - UpDelay *int `yaml:"up-delay,omitempty"` - DownDelay *int `yaml:"down-delay,omitempty"` + UpDelay IntString `yaml:"up-delay,omitempty"` + DownDelay IntString `yaml:"down-delay,omitempty"` FailOverMACPolicy IntString `yaml:"fail-over-mac-policy,omitempty"` // Netplan misspelled this as 'gratuitious-arp', not sure if it works with that name. // We may need custom handling of both spellings. diff --git a/network/netplan/netplan_test.go b/network/netplan/netplan_test.go index affa44fea230..6391f333b025 100644 --- a/network/netplan/netplan_test.go +++ b/network/netplan/netplan_test.go @@ -199,7 +199,7 @@ network: lacp-rate: fast mii-monitor-interval: 100 transmit-hash-policy: layer2 - up-delay: 0 + up-delay: "0" down-delay: 0 `) } @@ -231,7 +231,7 @@ network: mii-monitor-interval: 100 transmit-hash-policy: layer2 up-delay: 0 - down-delay: 0 + down-delay: "0" `) } @@ -355,7 +355,7 @@ network: parameters: mode: 802.3ad lacp-rate: fast - mii-monitor-interval: 100 + mii-monitor-interval: "100" min-links: 0 transmit-hash-policy: layer2 ad-select: 1