Documentation ¶
Index ¶
- Constants
- Variables
- func CalcGatewayIP(ipn *net.IPNet) net.IP
- func Create(name string, options entities.NetworkCreateOptions, ...) (*entities.NetworkCreateReport, error)
- func Exists(config *config.Config, name string) (bool, error)
- func FirstIPInSubnet(addr *net.IPNet) (net.IP, error)
- func GetBridgeNamesFromFileSystem(config *config.Config) ([]string, error)
- func GetCNIConfDir(configArg *config.Config) string
- func GetCNIConfigPathByName(config *config.Config, name string) (string, error)
- func GetCNIPlugins(list *libcni.NetworkConfigList) string
- func GetDefaultPodmanNetwork() (*net.IPNet, error)
- func GetFreeDeviceName(config *config.Config) (string, error)
- func GetFreeNetwork(config *config.Config) (*net.IPNet, error)
- func GetInterfaceNameFromConfig(path string) (string, error)
- func GetLiveNetworkNames() ([]string, error)
- func GetLiveNetworks() ([]*net.IPNet, error)
- func GetNetworkNamesFromFileSystem(config *config.Config) ([]string, error)
- func GetNetworksFromFilesystem(config *config.Config) ([]*allocator.Net, error)
- func HasDNSNamePlugin(paths []string) bool
- func InspectNetwork(config *config.Config, name string) (map[string]interface{}, error)
- func IsIPv6(netIP net.IP) bool
- 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(config *config.Config, name string) ([]byte, error)
- func RemoveInterface(interfaceName string) error
- func RemoveNetwork(config *config.Config, name string) error
- func ValidateUserNetworkIsAvailable(config *config.Config, userNet *net.IPNet) error
- type CNILock
- type CNIPlugins
- type DNSNameConfig
- type FirewallConfig
- type HostLocalBridge
- type IPAMDHCP
- type IPAMHostLocalConf
- type IPAMLocalHostRangeConf
- type IPAMRoute
- type MacVLANConfig
- type NcList
- type PortMapConfig
- type TuningConfig
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" // LockFileName is used for obtaining a lock and is appended // to libpod's tmpdir in practice LockFileName = "cni.lock" )
Variables ¶
var DefaultNetworkDriver = "bridge"
DefaultNetworkDriver is the default network type used
var ErrNoSuchNetworkInterface = errors.New("unable to find interface name for network")
ErrNoSuchNetworkInterface indicates that no network interface exists
var SupportedNetworkDrivers = []string{DefaultNetworkDriver}
SupportedNetworkDrivers describes the list of supported drivers
Functions ¶
func CalcGatewayIP ¶
CalcGatewayIP takes a network and returns the first IP in it.
func Create ¶
func Create(name string, options entities.NetworkCreateOptions, runtimeConfig *config.Config) (*entities.NetworkCreateReport, error)
Create the CNI network
func Exists ¶
Exists says whether a given network exists or not; it meant specifically for restful responses so 404s can be used
func FirstIPInSubnet ¶
FirstIPInSubnet gets the first IP in a subnet
func GetBridgeNamesFromFileSystem ¶
GetBridgeNamesFromFileSystem is a convenience function to get all the bridge names from the configured networks
func GetCNIConfDir ¶
GetCNIConfDir get CNI configuration directory
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 ¶
HasDNSNamePlugin looks to see if the dnsname cni plugin is present
func InspectNetwork ¶
InspectNetwork reads a CNI config and returns its configuration
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 ¶
RemoveNetwork removes a given network by name. If the network has container associated with it, that must be handled outside the context of this.
Types ¶
type CNILock ¶
CNILock is for preventing name collision and unpredictable results when doing some CNI operations.
type CNIPlugins ¶
CNIPlugins is a way of marshalling a CNI network configuration to disk
type DNSNameConfig ¶
type DNSNameConfig struct { PluginType string `json:"type"` DomainName string `json:"domainName"` Capabilities map[string]bool `json:"capabilities"` }
DNSNameConfig describes the dns container name resolution plugin config
func NewDNSNamePlugin ¶
func NewDNSNamePlugin(domainName string) DNSNameConfig
NewDNSNamePlugin creates the dnsname config with a given domainname
func (DNSNameConfig) Bytes ¶
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 ¶
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(routes []IPAMRoute, ipamRanges [][]IPAMLocalHostRangeConf) (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
func NewIPAMLocalHostRange ¶
func NewIPAMLocalHostRange(subnet *net.IPNet, ipRange *net.IPNet, gw net.IP) ([]IPAMLocalHostRangeConf, error)
NewIPAMLocalHostRange create a new IPAM range
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 for IPv4 or ::/0 for IPv6
func NewIPAMRoute ¶
NewIPAMRoute creates a new IPAM route configuration
type MacVLANConfig ¶
type MacVLANConfig struct { PluginType string `json:"type"` Master string `json:"master"` IPAM IPAMDHCP `json:"ipam"` }
MacVLANConfig describes the macvlan config
func NewMacVLANPlugin ¶
func NewMacVLANPlugin(device string) MacVLANConfig
NewMacVLANPlugin creates a macvlanconfig with a given device name
func (MacVLANConfig) Bytes ¶
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
type TuningConfig ¶
type TuningConfig struct {
PluginType string `json:"type"`
}
TuningConfig describes the tuning plugin
func NewTuningPlugin ¶
func NewTuningPlugin() TuningConfig
NewTuningPlugin creates a generic tuning section
func (TuningConfig) Bytes ¶
func (f TuningConfig) Bytes() ([]byte, error)
Bytes outputs the configuration as []byte