Fixed some convoluted texts in remote.md and fixed a remote driver bug
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
03c18818ed
commit
27d34d67ab
3 changed files with 11 additions and 10 deletions
|
@ -5,13 +5,13 @@ Remote driver is a special built-in driver. This driver in itself doesn't provid
|
|||
|
||||
## LibNetwork Integration
|
||||
|
||||
When LibNetwork creates an instance of the Built-in `Remote` Driver via the `New()` function, it provides a `DriverCallback` which implements the `RegisterDriver()` to let the Built-in Remote Driver to register any of the `Dynamic` Drivers/Plugins with LibNetwork's `NetworkController`
|
||||
When LibNetwork creates an instance of the Built-in `Remote` Driver via the `New()` function, it passes a `DriverCallback` as a parameter which implements the `RegisterDriver()`. The Built-in Remote Driver can use this interface to register any of the `Dynamic` Drivers/Plugins with LibNetwork's `NetworkController`
|
||||
|
||||
Refer to [Remote Driver Test](https://github.com/docker/libnetwork/blob/drivers/remote/driver_test.go) which provides an example of how the Built-In Remote driver can register any Dynamic driver with LibNetwork.
|
||||
Please Refer to [Remote Driver Test](https://github.com/docker/libnetwork/blob/master/drivers/remote/driver_test.go) which provides an example of registering a Dynamic driver with LibNetwork.
|
||||
|
||||
This design ensures that the implementation details of Dynamic Driver Registration mechanism is completely owned by the inbuilt-Remote driver and it also doesnt expose any of the driver layer to the North of LibNetwork (none of the LibNetwork client APIs are impacted).
|
||||
|
||||
When the inbuilt `Remote` driver detects a `Dynamic` Driver it will have to call the `registerRemoteDriver` method. This Method will take care of creating a new `Remote` Driver instance and associate it with the new `NetworkType` which is handled by the `Dynamic` Driver.
|
||||
When the inbuilt `Remote` driver detects a `Dynamic` Driver it can call the `registerRemoteDriver` method. This method will take care of creating a new `Remote` Driver instance with the passed 'NetworkType' and register it with Libnetwork's 'NetworkController
|
||||
|
||||
## Implementation
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var (
|
|||
// 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")
|
||||
ErrNotImplemented = errors.New("The API is not implemented yet")
|
||||
)
|
||||
|
||||
// Driver is an interface that every plugin driver needs to implement.
|
||||
|
|
|
@ -10,23 +10,24 @@ import (
|
|||
|
||||
var errNoCallback = errors.New("No Callback handler registered with Driver")
|
||||
|
||||
const networkType = "remote"
|
||||
const remoteNetworkType = "remote"
|
||||
|
||||
type driver struct {
|
||||
callback driverapi.DriverCallback
|
||||
networkType string
|
||||
callback driverapi.DriverCallback
|
||||
}
|
||||
|
||||
// New instance of remote driver returned to LibNetwork
|
||||
func New(dc driverapi.DriverCallback) (string, driverapi.Driver) {
|
||||
d := &driver{}
|
||||
d := &driver{networkType: remoteNetworkType}
|
||||
d.callback = dc
|
||||
return networkType, d
|
||||
return d.networkType, d
|
||||
}
|
||||
|
||||
// Internal Convenience method to register a remote driver.
|
||||
// The implementation of this method will change based on the dynamic driver registration design
|
||||
func (d *driver) registerRemoteDriver(networkType string) (driverapi.Driver, error) {
|
||||
newDriver := &driver{}
|
||||
newDriver := &driver{networkType: networkType}
|
||||
if d.callback == nil {
|
||||
return nil, errNoCallback
|
||||
}
|
||||
|
@ -71,5 +72,5 @@ func (d *driver) Leave(nid, eid types.UUID, options map[string]interface{}) erro
|
|||
}
|
||||
|
||||
func (d *driver) Type() string {
|
||||
return networkType
|
||||
return d.networkType
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue