Add disable flag for plugin Install.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
(cherry picked from commit 22e781e8e3
)
This commit is contained in:
parent
fcdd4d4a52
commit
82608cd4ce
2 changed files with 21 additions and 2 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
type pluginOptions struct {
|
||||
name string
|
||||
grantPerms bool
|
||||
disable bool
|
||||
}
|
||||
|
||||
func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||
|
@ -35,6 +36,7 @@ func newInstallCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|||
|
||||
flags := cmd.Flags()
|
||||
flags.BoolVar(&options.grantPerms, "grant-all-permissions", true, "grant all permissions necessary to run the plugin")
|
||||
flags.BoolVar(&options.disable, "disable", false, "do not enable the plugin on install")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -62,10 +64,9 @@ func runInstall(dockerCli *client.DockerCli, opts pluginOptions) error {
|
|||
|
||||
requestPrivilege := dockerCli.RegistryAuthenticationPrivilegedFunc(repoInfo.Index, "plugin install")
|
||||
|
||||
// TODO: pass acceptAllPermissions and noEnable flag
|
||||
options := types.PluginInstallOptions{
|
||||
RegistryAuth: encodedAuth,
|
||||
Disabled: false,
|
||||
Disabled: opts.disable,
|
||||
AcceptAllPermissions: opts.grantPerms,
|
||||
AcceptPermissionsFunc: acceptPrivileges(dockerCli, opts.name),
|
||||
PrivilegeFunc: requestPrivilege,
|
||||
|
|
|
@ -34,3 +34,21 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, nameWithTag)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
||||
name := "tiborvass/no-remove"
|
||||
tag := "latest"
|
||||
nameWithTag := name + ":" + tag
|
||||
|
||||
_, _, err := dockerCmdWithError("plugin", "install", name, "--disable")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, "false")
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, nameWithTag)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue