Browse code

Print plugin name on successful install, enable and disable.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>

Anusha Ragunathan authored on 2016/07/16 02:37:17
Showing 4 changed files
... ...
@@ -37,5 +37,9 @@ func runDisable(dockerCli *client.DockerCli, name string) error {
37 37
 	if !ok {
38 38
 		return fmt.Errorf("invalid name: %s", named.String())
39 39
 	}
40
-	return dockerCli.Client().PluginDisable(context.Background(), ref.String())
40
+	if err := dockerCli.Client().PluginDisable(context.Background(), ref.String()); err != nil {
41
+		return err
42
+	}
43
+	fmt.Fprintln(dockerCli.Out(), name)
44
+	return nil
41 45
 }
... ...
@@ -37,5 +37,9 @@ func runEnable(dockerCli *client.DockerCli, name string) error {
37 37
 	if !ok {
38 38
 		return fmt.Errorf("invalid name: %s", named.String())
39 39
 	}
40
-	return dockerCli.Client().PluginEnable(context.Background(), ref.String())
40
+	if err := dockerCli.Client().PluginEnable(context.Background(), ref.String()); err != nil {
41
+		return err
42
+	}
43
+	fmt.Fprintln(dockerCli.Out(), name)
44
+	return nil
41 45
 }
... ...
@@ -78,8 +78,11 @@ func runInstall(dockerCli *client.DockerCli, opts pluginOptions) error {
78 78
 		// TODO: Rename PrivilegeFunc, it has nothing to do with privileges
79 79
 		PrivilegeFunc: registryAuthFunc,
80 80
 	}
81
-
82
-	return dockerCli.Client().PluginInstall(ctx, ref.String(), options)
81
+	if err := dockerCli.Client().PluginInstall(ctx, ref.String(), options); err != nil {
82
+		return err
83
+	}
84
+	fmt.Fprintln(dockerCli.Out(), opts.name)
85
+	return nil
83 86
 }
84 87
 
85 88
 func acceptPrivileges(dockerCli *client.DockerCli, name string) func(privileges types.PluginPrivileges) (bool, error) {
... ...
@@ -3,54 +3,63 @@ package main
3 3
 import (
4 4
 	"github.com/docker/docker/pkg/integration/checker"
5 5
 	"github.com/go-check/check"
6
+
7
+	"strings"
8
+)
9
+
10
+var (
11
+	pName        = "tiborvass/no-remove"
12
+	pTag         = "latest"
13
+	pNameWithTag = pName + ":" + pTag
6 14
 )
7 15
 
8 16
 func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
9 17
 	testRequires(c, DaemonIsLinux, ExperimentalDaemon)
10
-	name := "tiborvass/no-remove"
11
-	tag := "latest"
12
-	nameWithTag := name + ":" + tag
13
-
14
-	_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", name)
18
+	_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
15 19
 	c.Assert(err, checker.IsNil)
16 20
 
17 21
 	out, _, err := dockerCmdWithError("plugin", "ls")
18 22
 	c.Assert(err, checker.IsNil)
19
-	c.Assert(out, checker.Contains, name)
20
-	c.Assert(out, checker.Contains, tag)
23
+	c.Assert(out, checker.Contains, pName)
24
+	c.Assert(out, checker.Contains, pTag)
21 25
 	c.Assert(out, checker.Contains, "true")
22 26
 
23
-	out, _, err = dockerCmdWithError("plugin", "inspect", nameWithTag)
27
+	out, _, err = dockerCmdWithError("plugin", "inspect", pNameWithTag)
24 28
 	c.Assert(err, checker.IsNil)
25 29
 	c.Assert(out, checker.Contains, "A test plugin for Docker")
26 30
 
27
-	out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
31
+	out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
28 32
 	c.Assert(out, checker.Contains, "is active")
29 33
 
30
-	_, _, err = dockerCmdWithError("plugin", "disable", nameWithTag)
34
+	_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
31 35
 	c.Assert(err, checker.IsNil)
32 36
 
33
-	out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
37
+	out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
34 38
 	c.Assert(err, checker.IsNil)
35
-	c.Assert(out, checker.Contains, nameWithTag)
39
+	c.Assert(out, checker.Contains, pNameWithTag)
36 40
 }
37 41
 
38 42
 func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
39 43
 	testRequires(c, DaemonIsLinux, ExperimentalDaemon)
40
-	name := "tiborvass/no-remove"
41
-	tag := "latest"
42
-	nameWithTag := name + ":" + tag
43
-
44
-	_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", name)
44
+	out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
45 45
 	c.Assert(err, checker.IsNil)
46
+	c.Assert(strings.TrimSpace(out), checker.Contains, pName)
46 47
 
47
-	out, _, err := dockerCmdWithError("plugin", "ls")
48
+	out, _, err = dockerCmdWithError("plugin", "ls")
48 49
 	c.Assert(err, checker.IsNil)
49 50
 	c.Assert(out, checker.Contains, "false")
50 51
 
51
-	out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
52
+	out, _, err = dockerCmdWithError("plugin", "enable", pName)
53
+	c.Assert(err, checker.IsNil)
54
+	c.Assert(strings.TrimSpace(out), checker.Contains, pName)
55
+
56
+	out, _, err = dockerCmdWithError("plugin", "disable", pName)
57
+	c.Assert(err, checker.IsNil)
58
+	c.Assert(strings.TrimSpace(out), checker.Contains, pName)
59
+
60
+	out, _, err = dockerCmdWithError("plugin", "remove", pName)
52 61
 	c.Assert(err, checker.IsNil)
53
-	c.Assert(out, checker.Contains, nameWithTag)
62
+	c.Assert(strings.TrimSpace(out), checker.Contains, pName)
54 63
 }
55 64
 
56 65
 func (s *DockerSuite) TestPluginInstallImage(c *check.C) {