Documentation
¶
Overview ¶
Package persist manages network configuration persistence to target OS.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderNetplan ¶
func RenderNetplan(cfg *NetworkConfig) string
RenderNetplan renders the configuration as netplan YAML. DNS and routes are placed under the first rendered stanza: ethernet if present, otherwise bond, otherwise VLAN.
func RenderNetworkdUnit ¶
func RenderNetworkdUnit(iface *InterfaceConfig) string
RenderNetworkdUnit renders a systemd-networkd .network unit for an interface.
Types ¶
type BondConfig ¶
type BondConfig struct {
Name string `json:"name"`
Members []string `json:"members"`
Mode string `json:"mode"`
Address string `json:"address,omitempty"`
Gateway string `json:"gateway,omitempty"`
MTU int `json:"mtu,omitempty"`
LACPRate string `json:"lacpRate,omitempty"`
HashPolicy string `json:"hashPolicy,omitempty"`
}
BondConfig describes a network bond.
type DNSConfig ¶
type DNSConfig struct {
Servers []string `json:"servers,omitempty"`
Search []string `json:"search,omitempty"`
}
DNSConfig holds DNS settings.
type InterfaceConfig ¶
type InterfaceConfig struct {
Name string `json:"name"`
MAC string `json:"mac,omitempty"`
DHCP bool `json:"dhcp,omitempty"`
Address string `json:"address,omitempty"` // CIDR notation.
Gateway string `json:"gateway,omitempty"`
MTU int `json:"mtu,omitempty"`
}
InterfaceConfig describes a network interface.
type NetworkConfig ¶
type NetworkConfig struct {
Interfaces []InterfaceConfig `json:"interfaces,omitempty"`
Bonds []BondConfig `json:"bonds,omitempty"`
VLANs []VLANConfig `json:"vlans,omitempty"`
DNS DNSConfig `json:"dns,omitempty"`
Routes []RouteConfig `json:"routes,omitempty"`
}
NetworkConfig holds the complete network configuration to persist.
func (*NetworkConfig) Validate ¶
func (c *NetworkConfig) Validate() error
Validate checks the network configuration.
type OSFamily ¶
type OSFamily string
OSFamily represents the target OS family.
func ParseOSFamily ¶
ParseOSFamily parses an OS family string.
func (OSFamily) ConfigPath ¶
ConfigPath returns the relative network config directory for the OS family.
type RouteConfig ¶
type RouteConfig struct {
Destination string `json:"destination"`
Gateway string `json:"gateway"`
Metric int `json:"metric,omitempty"`
}
RouteConfig describes a static route.