Browse code

Add disable flag for plugin Install.

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

Anusha Ragunathan authored on 2016/06/17 23:44:57
Showing 2 changed files
... ...
@@ -19,6 +19,7 @@ import (
19 19
 type pluginOptions struct {
20 20
 	name       string
21 21
 	grantPerms bool
22
+	disable    bool
22 23
 }
23 24
 
24 25
 func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
... ...
@@ -35,6 +36,7 @@ func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
35 35
 
36 36
 	flags := cmd.Flags()
37 37
 	flags.BoolVar(&options.grantPerms, "grant-all-permissions", true, "grant all permissions necessary to run the plugin")
38
+	flags.BoolVar(&options.disable, "disable", false, "do not enable the plugin on install")
38 39
 
39 40
 	return cmd
40 41
 }
... ...
@@ -62,10 +64,9 @@ func runInstall(dockerCli *client.DockerCli, opts pluginOptions) error {
62 62
 
63 63
 	requestPrivilege := dockerCli.RegistryAuthenticationPrivilegedFunc(repoInfo.Index, "plugin install")
64 64
 
65
-	// TODO: pass acceptAllPermissions and noEnable flag
66 65
 	options := types.PluginInstallOptions{
67 66
 		RegistryAuth:          encodedAuth,
68
-		Disabled:              false,
67
+		Disabled:              opts.disable,
69 68
 		AcceptAllPermissions:  opts.grantPerms,
70 69
 		AcceptPermissionsFunc: acceptPrivileges(dockerCli, opts.name),
71 70
 		PrivilegeFunc:         requestPrivilege,
... ...
@@ -34,3 +34,21 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
34 34
 	c.Assert(err, checker.IsNil)
35 35
 	c.Assert(out, checker.Contains, nameWithTag)
36 36
 }
37
+
38
+func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
39
+	testRequires(c, DaemonIsLinux, ExperimentalDaemon)
40
+	name := "tiborvass/no-remove"
41
+	tag := "latest"
42
+	nameWithTag := name + ":" + tag
43
+
44
+	_, _, err := dockerCmdWithError("plugin", "install", name, "--disable")
45
+	c.Assert(err, checker.IsNil)
46
+
47
+	out, _, err := dockerCmdWithError("plugin", "ls")
48
+	c.Assert(err, checker.IsNil)
49
+	c.Assert(out, checker.Contains, "false")
50
+
51
+	out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
52
+	c.Assert(err, checker.IsNil)
53
+	c.Assert(out, checker.Contains, nameWithTag)
54
+}