1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove plugin root from filesystem.

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

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This commit is contained in:
Anusha Ragunathan 2016-07-27 13:38:13 -07:00
parent 297745b1cd
commit 5690730a74
2 changed files with 20 additions and 2 deletions

View file

@ -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) {

View file

@ -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 {