Skip to content

Commit

Permalink
fix: allow some netplan values to be string or int
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
manadart committed Oct 28, 2024
1 parent 5043424 commit 2ea9707
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions network/netplan/netplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions network/netplan/netplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ network:
mii-monitor-interval: 100
transmit-hash-policy: layer2
up-delay: 0
down-delay: 0
down-delay: "0"
`)
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2ea9707

Please sign in to comment.