Browse code

Add only legacy plugins to the legacy lookup map.

Legacy plugin model maintained a map of plugins. This is
not used by the new model. Using this map in the new model
causes incorrect lookup of plugins. This change uses adds
a plugin to the map only if its legacy.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>

Anusha Ragunathan authored on 2016/07/19 07:39:27
Showing 4 changed files
... ...
@@ -83,6 +83,11 @@ func (p *Plugin) Client() *Client {
83 83
 	return p.client
84 84
 }
85 85
 
86
+// IsLegacy returns true for legacy plugins and false otherwise.
87
+func (p *Plugin) IsLegacy() bool {
88
+	return true
89
+}
90
+
86 91
 // NewLocalPlugin creates a new local plugin.
87 92
 func NewLocalPlugin(name, addr string) *Plugin {
88 93
 	return &Plugin{
... ...
@@ -6,4 +6,5 @@ import "github.com/docker/docker/pkg/plugins"
6 6
 type Plugin interface {
7 7
 	Client() *plugins.Client
8 8
 	Name() string
9
+	IsLegacy() bool
9 10
 }
... ...
@@ -54,6 +54,11 @@ func (p *plugin) Client() *plugins.Client {
54 54
 	return p.client
55 55
 }
56 56
 
57
+// IsLegacy returns true for legacy plugins and false otherwise.
58
+func (p *plugin) IsLegacy() bool {
59
+	return false
60
+}
61
+
57 62
 func (p *plugin) Name() string {
58 63
 	name := p.P.Name
59 64
 	if len(p.P.Tag) > 0 {
... ...
@@ -118,7 +118,9 @@ func lookup(name string) (volume.Driver, error) {
118 118
 		return nil, err
119 119
 	}
120 120
 
121
-	drivers.extensions[name] = d
121
+	if p.IsLegacy() {
122
+		drivers.extensions[name] = d
123
+	}
122 124
 	return d, nil
123 125
 }
124 126
 
... ...
@@ -174,7 +176,9 @@ func GetAllDrivers() ([]volume.Driver, error) {
174 174
 		}
175 175
 
176 176
 		ext = NewVolumeDriver(name, p.Client())
177
-		drivers.extensions[name] = ext
177
+		if p.IsLegacy() {
178
+			drivers.extensions[name] = ext
179
+		}
178 180
 		ds = append(ds, ext)
179 181
 	}
180 182
 	return ds, nil