Documentation ¶
Index ¶
- Constants
- Variables
- func CalcGatewayIP(ipn *net.IPNet) net.IP
- func FirstIPInSubnet(addr *net.IPNet) (net.IP, error)
- func GetBridgeNamesFromFileSystem() ([]string, error)
- func GetCNIConfigPathByName(name string) (string, error)
- func GetCNIPlugins(list *libcni.NetworkConfigList) string
- func GetDefaultPodmanNetwork() (*net.IPNet, error)
- func GetFreeDeviceName() (string, error)
- func GetFreeNetwork() (*net.IPNet, error)
- func GetInterfaceNameFromConfig(path string) (string, error)
- func GetLiveNetworkNames() ([]string, error)
- func GetLiveNetworks() ([]*net.IPNet, error)
- func GetNetworkNamesFromFileSystem() ([]string, error)
- func GetNetworksFromFilesystem() ([]*allocator.Net, error)
- func HasDNSNamePlugin(paths []string) bool
- func InspectNetwork(name string) (map[string]interface{}, error)
- func IsSupportedDriver(driver string) error
- func LastIPInSubnet(addr *net.IPNet) (net.IP, error)
- func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error)
- func NextSubnet(subnet *net.IPNet) (*net.IPNet, error)
- func ReadRawCNIConfByName(name string) ([]byte, error)
- func RemoveInterface(interfaceName string) error
- func RemoveNetwork(name string) error
- func ValidateUserNetworkIsAvailable(userNet *net.IPNet) error
- type CNIPlugins
- type DNSNameConfig
- type FirewallConfig
- type HostLocalBridge
- type IPAMDHCP
- type IPAMHostLocalConf
- type IPAMLocalHostRangeConf
- type IPAMRoute
- type MacVLANConfig
- type NcList
- type PortMapConfig
Constants ¶
const ( // CNIConfigDir is the path where CNI config files exist CNIConfigDir = "/etc/cni/net.d" // CNIDeviceName is the default network device name and in // reality should have an int appended to it (cni-podman4) CNIDeviceName = "cni-podman" // DefaultPodmanDomainName is used for the dnsname plugin to define // a localized domain name for a created network DefaultPodmanDomainName = "dns.podman" )
Variables ¶
var (
ErrNetworkNotFound = errors.New("network not found")
)
var SupportedNetworkDrivers = []string{"bridge"}
SupportedNetworkDrivers describes the list of supported drivers
Functions ¶
func CalcGatewayIP ¶
CalcGatewayIP takes a network and returns the first IP in it.
func FirstIPInSubnet ¶
FirstIPInSubnet gets the first IP in a subnet
func GetBridgeNamesFromFileSystem ¶ added in v1.6.3
GetBridgeNamesFromFileSystem is a convenience function to get all the bridge names from the configured networks
func GetCNIConfigPathByName ¶
GetCNIConfigPathByName finds a CNI network by name and returns its configuration file path
func GetCNIPlugins ¶
func GetCNIPlugins(list *libcni.NetworkConfigList) string
GetCNIPlugins returns a list of plugins that a given network has in the form of a string
func GetDefaultPodmanNetwork ¶
GetDefaultPodmanNetwork outputs the default network for podman
func GetFreeDeviceName ¶
GetFreeDeviceName returns a device name that is unused; used when no network name is provided by user
func GetFreeNetwork ¶
GetFreeNetwork looks for a free network according to existing cni configuration files and network interfaces.
func GetInterfaceNameFromConfig ¶
GetInterfaceNameFromConfig returns the interface name for the bridge plugin
func GetLiveNetworkNames ¶
GetLiveNetworkNames returns a list of network interfaces on the system
func GetLiveNetworks ¶
GetLiveNetworks returns a slice of networks representing what the system has defined as network interfaces
func GetNetworkNamesFromFileSystem ¶
GetNetworkNamesFromFileSystem gets all the names from the cni network configuration files
func GetNetworksFromFilesystem ¶
GetNetworksFromFilesystem gets all the networks from the cni configuration files
func HasDNSNamePlugin ¶ added in v1.6.3
HasDNSNamePlugin looks to see if the dnsname cni plugin is present
func InspectNetwork ¶ added in v1.7.0
InspectNetwork reads a CNI config and returns its configuration
func IsSupportedDriver ¶
IsSupportedDriver checks if the user provided driver is supported
func LastIPInSubnet ¶
LastIPInSubnet gets the last IP in a subnet
func LoadCNIConfsFromDir ¶
func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error)
LoadCNIConfsFromDir loads all the CNI configurations from a dir
func NextSubnet ¶
NextSubnet returns subnet incremented by 1
func ReadRawCNIConfByName ¶
ReadRawCNIConfByName reads the raw CNI configuration for a CNI network by name
func RemoveInterface ¶
RemoveInterface removes an interface by the given name
func RemoveNetwork ¶ added in v1.7.0
RemoveNetwork removes a given network by name. If the network has container associated with it, that must be handled outside the context of this.
func ValidateUserNetworkIsAvailable ¶
ValidateUserNetworkIsAvailable returns via an error if a network is available to be used
Types ¶
type CNIPlugins ¶
CNIPlugins is a way of marshalling a CNI network configuration to disk
type DNSNameConfig ¶ added in v1.6.3
DNSNameConfig describes the dns container name resolution plugin config
func NewDNSNamePlugin ¶ added in v1.6.3
func NewDNSNamePlugin(domainName string) DNSNameConfig
NewDNSNamePlugin creates the dnsname config with a given domainname
func (DNSNameConfig) Bytes ¶ added in v1.6.3
func (d DNSNameConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type FirewallConfig ¶
FirewallConfig describes the firewall plugin
func NewFirewallPlugin ¶
func NewFirewallPlugin() FirewallConfig
NewFirewallPlugin creates a generic firewall plugin
func (FirewallConfig) Bytes ¶
func (f FirewallConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type HostLocalBridge ¶
type HostLocalBridge struct { PluginType string `json:"type"` BrName string `json:"bridge,omitempty"` IsGW bool `json:"isGateway"` IsDefaultGW bool `json:"isDefaultGateway,omitempty"` ForceAddress bool `json:"forceAddress,omitempty"` IPMasq bool `json:"ipMasq,omitempty"` MTU int `json:"mtu,omitempty"` HairpinMode bool `json:"hairpinMode,omitempty"` PromiscMode bool `json:"promiscMode,omitempty"` Vlan int `json:"vlan,omitempty"` IPAM IPAMHostLocalConf `json:"ipam"` }
HostLocalBridge describes a configuration for a bridge plugin https://github.com/containernetworking/plugins/tree/master/plugins/main/bridge#network-configuration-reference
func NewHostLocalBridge ¶
func NewHostLocalBridge(name string, isGateWay, isDefaultGW, ipMasq bool, ipamConf IPAMHostLocalConf) *HostLocalBridge
NewHostLocalBridge creates a new LocalBridge for host-local
func (*HostLocalBridge) Bytes ¶
func (h *HostLocalBridge) Bytes() ([]byte, error)
Bytes outputs []byte
type IPAMDHCP ¶ added in v1.7.0
type IPAMDHCP struct {
DHCP string `json:"type"`
}
IPAMDHCP describes the ipamdhcp config
type IPAMHostLocalConf ¶
type IPAMHostLocalConf struct { PluginType string `json:"type"` Routes []IPAMRoute `json:"routes,omitempty"` ResolveConf string `json:"resolveConf,omitempty"` DataDir string `json:"dataDir,omitempty"` Ranges [][]IPAMLocalHostRangeConf `json:"ranges,omitempty"` }
IPAMHostLocalConf describes an IPAM configuration https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local#network-configuration-reference
func NewIPAMHostLocalConf ¶
func NewIPAMHostLocalConf(subnet *net.IPNet, routes []IPAMRoute, ipRange net.IPNet, gw net.IP) (IPAMHostLocalConf, error)
NewIPAMHostLocalConf creates a new IPAMHostLocal configfuration
func (IPAMHostLocalConf) Bytes ¶
func (i IPAMHostLocalConf) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type IPAMLocalHostRangeConf ¶
type IPAMLocalHostRangeConf struct { Subnet string `json:"subnet"` RangeStart string `json:"rangeStart,omitempty"` RangeEnd string `json:"rangeEnd,omitempty"` Gateway string `json:"gateway,omitempty"` }
IPAMLocalHostRangeConf describes the new style IPAM ranges
type IPAMRoute ¶
type IPAMRoute struct {
Dest string `json:"dst"`
}
IPAMRoute describes a route in an ipam config
func NewIPAMDefaultRoute ¶
NewIPAMDefaultRoute creates a new IPAMDefault route of 0.0.0.0/0
func NewIPAMRoute ¶
NewIPAMRoute creates a new IPAM route configuration
type MacVLANConfig ¶ added in v1.7.0
type MacVLANConfig struct { PluginType string `json:"type"` Master string `json:"master"` IPAM IPAMDHCP `json:"ipam"` }
MacVLANConfig describes the macvlan config
func NewMacVLANPlugin ¶ added in v1.7.0
func NewMacVLANPlugin(device string) MacVLANConfig
NewMacVLANPlugin creates a macvlanconfig with a given device name
func (MacVLANConfig) Bytes ¶ added in v1.7.0
func (p MacVLANConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte
type PortMapConfig ¶
type PortMapConfig struct { PluginType string `json:"type"` Capabilities map[string]bool `json:"capabilities"` }
PortMapConfig describes the default portmapping config
func NewPortMapPlugin ¶
func NewPortMapPlugin() PortMapConfig
NewPortMapPlugin creates a predefined, default portmapping configuration
func (PortMapConfig) Bytes ¶
func (p PortMapConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte