Browse code

Fix removing plugins

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 5e156fd3d4b21267caca093dd0df7ed6bce85535)

Brian Goff authored on 2016/06/16 00:21:31
Showing 2 changed files
... ...
@@ -76,10 +76,6 @@ func (pm *Manager) Pull(name string, metaHeader http.Header, authConfig *types.A
76 76
 	}
77 77
 
78 78
 	p := pm.newPlugin(ref, pluginID)
79
-	if ref, ok := ref.(reference.NamedTagged); ok {
80
-		p.p.Tag = ref.Tag()
81
-	}
82
-
83 79
 	if err := pm.initPlugin(p); err != nil {
84 80
 		return nil, err
85 81
 	}
... ...
@@ -58,7 +58,12 @@ func (p *plugin) Client() *plugins.Client {
58 58
 }
59 59
 
60 60
 func (p *plugin) Name() string {
61
-	return p.p.Name
61
+	name := p.p.Name
62
+	if len(p.p.Tag) > 0 {
63
+		// TODO: this feels hacky, maybe we should be storing the distribution reference rather than splitting these
64
+		name += ":" + p.p.Tag
65
+	}
66
+	return name
62 67
 }
63 68
 
64 69
 func (pm *Manager) newPlugin(ref reference.Named, id string) *plugin {
... ...
@@ -300,12 +305,13 @@ func (pm *Manager) initPlugin(p *plugin) error {
300 300
 
301 301
 func (pm *Manager) remove(p *plugin) error {
302 302
 	if p.p.Active {
303
-		return fmt.Errorf("plugin %s is active", p.p.Name)
303
+		return fmt.Errorf("plugin %s is active", p.Name())
304 304
 	}
305 305
 	pm.Lock() // fixme: lock single record
306 306
 	defer pm.Unlock()
307 307
 	os.RemoveAll(p.stateSourcePath)
308
-	delete(pm.plugins, p.p.Name)
308
+	delete(pm.plugins, p.p.ID)
309
+	delete(pm.nameToID, p.Name())
309 310
 	pm.save()
310 311
 	return nil
311 312
 }