Explorar o código

Remove plugin root from filesystem.

`docker plugin remove` didnt actually remove plugin from disk. Fix that.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Anusha Ragunathan %!s(int64=9) %!d(string=hai) anos
pai
achega
5690730a74
Modificáronse 2 ficheiros con 20 adicións e 2 borrados
  1. 19 1
      integration-cli/docker_cli_plugins_test.go
  2. 1 1
      plugin/manager.go

+ 19 - 1
integration-cli/docker_cli_plugins_test.go

@@ -4,6 +4,10 @@ import (
 	"github.com/docker/docker/pkg/integration/checker"
 	"github.com/go-check/check"
 
+	"io/ioutil"
+	"os"
+	"os/exec"
+	"path/filepath"
 	"strings"
 )
 
@@ -26,7 +30,16 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
 
 	out, _, err = dockerCmdWithError("plugin", "inspect", pNameWithTag)
 	c.Assert(err, checker.IsNil)
-	c.Assert(out, checker.Contains, "A test plugin for Docker")
+	tmpFile, err := ioutil.TempFile("", "inspect.json")
+	c.Assert(err, checker.IsNil)
+	defer tmpFile.Close()
+
+	if _, err := tmpFile.Write([]byte(out)); err != nil {
+		c.Fatal(err)
+	}
+	// FIXME: When `docker plugin inspect` takes a format as input, jq can be replaced.
+	id, err := exec.Command("jq", ".Id", "--raw-output", tmpFile.Name()).CombinedOutput()
+	c.Assert(err, checker.IsNil)
 
 	out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
 	c.Assert(out, checker.Contains, "is active")
@@ -37,6 +50,11 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
 	out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
 	c.Assert(err, checker.IsNil)
 	c.Assert(out, checker.Contains, pNameWithTag)
+
+	_, err = os.Stat(filepath.Join(dockerBasePath, "plugins", string(id)))
+	if !os.IsNotExist(err) {
+		c.Fatal(err)
+	}
 }
 
 func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {

+ 1 - 1
plugin/manager.go

@@ -372,7 +372,7 @@ func (pm *Manager) remove(p *plugin) error {
 	delete(pm.plugins, p.PluginObj.ID)
 	delete(pm.nameToID, p.Name())
 	pm.save()
-	return nil
+	return os.RemoveAll(filepath.Join(pm.libRoot, p.PluginObj.ID))
 }
 
 func (pm *Manager) set(p *plugin, args []string) error {