README
¶
Docker network extension API
Go handler to create external network extensions for Docker.
Usage
This library is designed to be integrated in your program.
- Implement the
network.Driver
interface. - Initialize a
network.Handler
with your implementation. - Call either
ServeTCP
orServeUnix
from thenetwork.Handler
.
Example using TCP sockets:
import "github.com/docker/go-plugins-helpers/network"
d := MyNetworkDriver{}
h := network.NewHandler(d)
h.ServeTCP("test_network", ":8080")
Example using Unix sockets:
import "github.com/docker/go-plugins-helpers/network"
d := MyNetworkDriver{}
h := network.NewHandler(d)
h.ServeUnix("root", "test_network")
Full example plugins
- docker-ovs-plugin - An Open vSwitch Networking Plugin
Documentation
¶
Index ¶
- Constants
- type CapabilitiesResponse
- type CreateEndpointRequest
- type CreateNetworkRequest
- type DeleteEndpointRequest
- type DeleteNetworkRequest
- type Driver
- type EndpointInterface
- type ErrorResponse
- type Handler
- type IPAMData
- type InfoRequest
- type InfoResponse
- type InterfaceName
- type JoinRequest
- type JoinResponse
- type LeaveRequest
- type StaticRoute
Constants ¶
const (
// LocalScope is the correct scope response for a local scope driver
LocalScope = `local`
// GlobalScope is the correct scope response for a global scope driver
GlobalScope = `global`
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CapabilitiesResponse ¶
type CapabilitiesResponse struct {
Scope string
}
CapabilitiesResponse returns whether or not this network is global or local
type CreateEndpointRequest ¶
type CreateEndpointRequest struct {
NetworkID string
EndpointID string
Interface *EndpointInterface
Options map[string]interface{}
}
CreateEndpointRequest is sent by the daemon when an endpoint should be created
type CreateNetworkRequest ¶
type CreateNetworkRequest struct {
NetworkID string
Options map[string]interface{}
IPv4Data []*IPAMData
IPv6Data []*IPAMData
}
CreateNetworkRequest is sent by the daemon when a network needs to be created
type DeleteEndpointRequest ¶
type DeleteEndpointRequest struct {
NetworkID string
EndpointID string
}
DeleteEndpointRequest is sent by the daemon when an endpoint needs to be removed
type DeleteNetworkRequest ¶
type DeleteNetworkRequest struct {
NetworkID string
}
DeleteNetworkRequest is sent by the daemon when a network needs to be removed
type Driver ¶
type Driver interface {
GetCapabilities() (*CapabilitiesResponse, error)
CreateNetwork(*CreateNetworkRequest) error
DeleteNetwork(*DeleteNetworkRequest) error
CreateEndpoint(*CreateEndpointRequest) error
DeleteEndpoint(*DeleteEndpointRequest) error
EndpointInfo(*InfoRequest) (*InfoResponse, error)
Join(*JoinRequest) (*JoinResponse, error)
Leave(*LeaveRequest) error
}
Driver represent the interface a driver must fulfill.
type EndpointInterface ¶
type EndpointInterface struct {
Address string
AddressIPv6 string
MacAddress string
}
EndpointInterface contains endpoint interface information
type ErrorResponse ¶
type ErrorResponse struct {
Err string
}
ErrorResponse is a formatted error message that libnetwork can understand
func NewErrorResponse ¶
func NewErrorResponse(msg string) *ErrorResponse
NewErrorResponse creates an ErrorResponse with the provided message
type Handler ¶
type Handler struct {
sdk.Handler
// contains filtered or unexported fields
}
Handler forwards requests and responses between the docker daemon and the plugin.
func NewHandler ¶
func NewHandler(driver Driver) *Handler
NewHandler initializes the request handler with a driver implementation.
type IPAMData ¶
type IPAMData struct {
AddressSpace string
Pool string
Gateway string
AuxAddresses map[string]interface{}
}
IPAMData contains IPv4 or IPv6 addressing information
type InfoRequest ¶
type InfoRequest struct {
NetworkID string
EnpointID string
}
InfoRequest is send by the daemon when querying endpoint information
type InfoResponse ¶
type InfoResponse struct {
Value map[string]string
}
InfoResponse is endpoint information sent in response to an InfoRequest
type InterfaceName ¶
type InterfaceName struct {
SrcName string
DstPrefix string
}
InterfaceName consists of the name of the interface in the global netns and the desired prefix to be appended to the interface inside the container netns
type JoinRequest ¶
type JoinRequest struct {
NetworkID string
EndpointID string
SandboxKey string
Options map[string]interface{}
}
JoinRequest is sent by the Daemon when an endpoint needs be joined to a network
type JoinResponse ¶
type JoinResponse struct {
Gateway string
InterfaceName InterfaceName
StaticRoutes []*StaticRoute
}
JoinResponse is sent in response to a JoinRequest
type LeaveRequest ¶
type LeaveRequest struct {
NetworkID string
EndpointID string
Options map[string]interface{}
}
LeaveRequest is send by the daemon when a endpoint is leaving a network
type StaticRoute ¶
type StaticRoute struct {
Destination string
RouteType int
NextHop string
}
StaticRoute contains static route information