Skip to content

Commit

Permalink
Remove plugin root from filesystem.
Browse files Browse the repository at this point in the history
`docker plugin remove` didnt actually remove plugin from disk. Fix that.

Signed-off-by: Anusha Ragunathan <[email protected]>
(cherry picked from commit 5690730)
Signed-off-by: Tibor Vass <[email protected]>
  • Loading branch information
anusha-ragunathan authored and Tibor Vass committed Aug 12, 2016
1 parent 9ba749a commit 828a247
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion integration-cli/docker_cli_plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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")
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 828a247

Please sign in to comment.