Browse code

Make `docker volume list` lookup plugins installed using new model.

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

Anusha Ragunathan authored on 2016/08/17 07:53:43
Showing 3 changed files
... ...
@@ -206,6 +206,13 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
206 206
 		}
207 207
 	}()
208 208
 
209
+	out, err = s.d.Cmd("volume", "ls")
210
+	if err != nil {
211
+		c.Fatalf("Could not list volume: %v %s", err, out)
212
+	}
213
+	c.Assert(out, checker.Contains, volName)
214
+	c.Assert(out, checker.Contains, pluginName)
215
+
209 216
 	mountPoint, err := s.d.Cmd("volume", "inspect", volName, "--format", "{{.Mountpoint}}")
210 217
 	if err != nil {
211 218
 		c.Fatalf("Could not inspect volume: %v %s", err, mountPoint)
... ...
@@ -181,14 +181,13 @@ func FindWithCapability(capability string) ([]Plugin, error) {
181 181
 		handleLegacy = manager.handleLegacy
182 182
 		manager.RLock()
183 183
 		defer manager.RUnlock()
184
-	pluginLoop:
185 184
 		for _, p := range manager.plugins {
186 185
 			for _, typ := range p.PluginObj.Manifest.Interface.Types {
187
-				if typ.Capability != capability || typ.Prefix != "docker" {
188
-					continue pluginLoop
186
+				if strings.EqualFold(typ.Capability, capability) && typ.Prefix == "docker" {
187
+					result = append(result, p)
188
+					break
189 189
 				}
190 190
 			}
191
-			result = append(result, p)
192 191
 		}
193 192
 	}
194 193
 	if handleLegacy {
... ...
@@ -244,9 +243,8 @@ func LookupWithCapability(name, capability string) (Plugin, error) {
244 244
 		return nil, err
245 245
 	}
246 246
 
247
-	capability = strings.ToLower(capability)
248 247
 	for _, typ := range p.PluginObj.Manifest.Interface.Types {
249
-		if typ.Capability == capability && typ.Prefix == "docker" {
248
+		if strings.EqualFold(typ.Capability, capability) && typ.Prefix == "docker" {
250 249
 			return p, nil
251 250
 		}
252 251
 	}
... ...
@@ -107,7 +107,7 @@ func lookup(name string) (volume.Driver, error) {
107 107
 		return nil, fmt.Errorf("Error looking up volume plugin %s: %v", name, err)
108 108
 	}
109 109
 
110
-	d := NewVolumeDriver(name, p.Client())
110
+	d := NewVolumeDriver(p.Name(), p.Client())
111 111
 	if err := validateDriver(d); err != nil {
112 112
 		return nil, err
113 113
 	}