diff --git a/libnetwork/docs/remote.md b/libnetwork/docs/remote.md index 96e91720a9..5d552972a4 100644 --- a/libnetwork/docs/remote.md +++ b/libnetwork/docs/remote.md @@ -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 diff --git a/libnetwork/driverapi/driverapi.go b/libnetwork/driverapi/driverapi.go index a6b7bfc5a2..50c39279e4 100644 --- a/libnetwork/driverapi/driverapi.go +++ b/libnetwork/driverapi/driverapi.go @@ -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. diff --git a/libnetwork/drivers/remote/driver.go b/libnetwork/drivers/remote/driver.go index ae1de3ded0..c23ee0e332 100644 --- a/libnetwork/drivers/remote/driver.go +++ b/libnetwork/drivers/remote/driver.go @@ -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 }