Remote Driver Registration

This commits brings in a functionality for remote drivers to register
with LibNetwork. The Built-In remote driver is responsible for the
actual "remote" plugin to be made available.

Having such a mechanism makes libnetwork core not dependent on any
external plugin mechanism and also the Libnetwork NB apis are free of
Driver interface.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal
2015-05-06 21:45:30 -07:00
parent 914b9a56c6
commit 0011d46ead
13 changed files with 184 additions and 20 deletions
+17
View File
@@ -2,6 +2,7 @@ package driverapi
import (
"errors"
"fmt"
"github.com/docker/libnetwork/sandbox"
"github.com/docker/libnetwork/types"
@@ -14,6 +15,8 @@ var (
ErrNoNetwork = errors.New("No network exists")
// ErrNoEndpoint is returned if no endpoint with the specified id exists
ErrNoEndpoint = errors.New("No endpoint exists")
// ErrNotImplemented is returned when a Driver has not implemented an API yet
ErrNotImplemented = errors.New("The API is not implemneted yet")
)
// Driver is an interface that every plugin driver needs to implement.
@@ -58,3 +61,17 @@ type Driver interface {
type JoinInfo struct {
HostsPath string
}
// ErrActiveRegistration represents an error when a driver is registered to a networkType that is previously registered
type ErrActiveRegistration string
// Error interface for ErrActiveRegistration
func (ar ErrActiveRegistration) Error() string {
return fmt.Sprintf("Driver already registered for type %q", string(ar))
}
// DriverCallback provides a Callback interface for Drivers into LibNetwork
type DriverCallback interface {
// RegisterDriver provides a way for Remote drivers to dynamically register new NetworkType and associate with a driver instance
RegisterDriver(name string, driver Driver) error
}