From 5690730a7471726bbaf813e634a7117a562dfb8c Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Wed, 27 Jul 2016 13:38:13 -0700 Subject: [PATCH] Remove plugin root from filesystem. `docker plugin remove` didnt actually remove plugin from disk. Fix that. Signed-off-by: Anusha Ragunathan --- integration-cli/docker_cli_plugins_test.go | 20 +++++++++++++++++++- plugin/manager.go | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go index ca1b7d2b8f..c873b75b5d 100644 --- a/integration-cli/docker_cli_plugins_test.go +++ b/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) { diff --git a/plugin/manager.go b/plugin/manager.go index 6f0bf57788..fae852b1d1 100644 --- a/plugin/manager.go +++ b/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 {