Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions v2/network_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ type NetworkConfig struct {
VLANs VLANs `yaml:"vlans,omitempty"`
}

type NetworkConfigForMarshalling struct {
VersionMustBe2 uint8 `yaml:"version"`
Renderer *Renderer `yaml:"renderer,omitempty"`
Ethernets Ethernets `yaml:"ethernets,omitempty"`
Wifis Wifis `yaml:"wifis,omitempty"`
Bridges Bridges `yaml:"bridges,omitempty"`
Bonds Bonds `yaml:"bonds,omitempty"`
Tunnels Tunnels `yaml:"tunnels,omitempty"`
VLANs VLANs `yaml:"vlans,omitempty"`
}

type networkConfigForUnmarshalling struct {
Renderer *Renderer `yaml:"renderer,omitempty"`
Ethernets Ethernets `yaml:"ethernets,omitempty"`
Expand All @@ -28,8 +39,18 @@ type networkConfigForUnmarshalling struct {
// MarshalYAML marshals NetworkConfig as YAML.
// This method used on marshaling YAML internally.
func (n *NetworkConfig) MarshalYAML() (interface{}, error) {
n.VersionMustBe2 = networkVersion2
return n, nil
nm := NetworkConfigForMarshalling{
VersionMustBe2: networkVersion2,
Renderer: n.Renderer,
Ethernets: n.Ethernets,
Wifis: n.Wifis,
Bridges: n.Bridges,
Bonds: n.Bonds,
Tunnels: n.Tunnels,
VLANs: n.VLANs,
}

return nm, nil
}

// UnmarshalYAML unmarshals NetworkConfig as YAML.
Expand Down