Browse code

Fixed some convoluted texts in remote.md and fixed a remote driver bug

Signed-off-by: Madhu Venugopal <madhu@docker.com>

Madhu Venugopal authored on 2015/05/07 16:48:12
Showing 3 changed files
... ...
@@ -5,13 +5,13 @@ Remote driver is a special built-in driver. This driver in itself doesn't provid
5 5
 
6 6
 ## LibNetwork Integration
7 7
 
8
-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`
8
+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`
9 9
 
10
-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.
10
+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.
11 11
 
12 12
 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).
13 13
 
14
-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.
14
+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
15 15
 
16 16
 ## Implementation
17 17
 
... ...
@@ -16,7 +16,7 @@ var (
16 16
 	// ErrNoEndpoint is returned if no endpoint with the specified id exists
17 17
 	ErrNoEndpoint = errors.New("No endpoint exists")
18 18
 	// ErrNotImplemented is returned when a Driver has not implemented an API yet
19
-	ErrNotImplemented = errors.New("The API is not implemneted yet")
19
+	ErrNotImplemented = errors.New("The API is not implemented yet")
20 20
 )
21 21
 
22 22
 // Driver is an interface that every plugin driver needs to implement.
... ...
@@ -10,23 +10,24 @@ import (
10 10
 
11 11
 var errNoCallback = errors.New("No Callback handler registered with Driver")
12 12
 
13
-const networkType = "remote"
13
+const remoteNetworkType = "remote"
14 14
 
15 15
 type driver struct {
16
-	callback driverapi.DriverCallback
16
+	networkType string
17
+	callback    driverapi.DriverCallback
17 18
 }
18 19
 
19 20
 // New instance of remote driver returned to LibNetwork
20 21
 func New(dc driverapi.DriverCallback) (string, driverapi.Driver) {
21
-	d := &driver{}
22
+	d := &driver{networkType: remoteNetworkType}
22 23
 	d.callback = dc
23
-	return networkType, d
24
+	return d.networkType, d
24 25
 }
25 26
 
26 27
 // Internal Convenience method to register a remote driver.
27 28
 // The implementation of this method will change based on the dynamic driver registration design
28 29
 func (d *driver) registerRemoteDriver(networkType string) (driverapi.Driver, error) {
29
-	newDriver := &driver{}
30
+	newDriver := &driver{networkType: networkType}
30 31
 	if d.callback == nil {
31 32
 		return nil, errNoCallback
32 33
 	}
... ...
@@ -71,5 +72,5 @@ func (d *driver) Leave(nid, eid types.UUID, options map[string]interface{}) erro
71 71
 }
72 72
 
73 73
 func (d *driver) Type() string {
74
-	return networkType
74
+	return d.networkType
75 75
 }