mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #24692 from anusha-ragunathan/plugins-ux
Print plugin name on successful install, enable and disable.
This commit is contained in:
commit
340964db1c
4 changed files with 44 additions and 24 deletions
|
@ -37,5 +37,9 @@ func runDisable(dockerCli *client.DockerCli, name string) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("invalid name: %s", named.String())
|
return fmt.Errorf("invalid name: %s", named.String())
|
||||||
}
|
}
|
||||||
return dockerCli.Client().PluginDisable(context.Background(), ref.String())
|
if err := dockerCli.Client().PluginDisable(context.Background(), ref.String()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Fprintln(dockerCli.Out(), name)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,9 @@ func runEnable(dockerCli *client.DockerCli, name string) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("invalid name: %s", named.String())
|
return fmt.Errorf("invalid name: %s", named.String())
|
||||||
}
|
}
|
||||||
return dockerCli.Client().PluginEnable(context.Background(), ref.String())
|
if err := dockerCli.Client().PluginEnable(context.Background(), ref.String()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Fprintln(dockerCli.Out(), name)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,11 @@ func runInstall(dockerCli *client.DockerCli, opts pluginOptions) error {
|
||||||
// TODO: Rename PrivilegeFunc, it has nothing to do with privileges
|
// TODO: Rename PrivilegeFunc, it has nothing to do with privileges
|
||||||
PrivilegeFunc: registryAuthFunc,
|
PrivilegeFunc: registryAuthFunc,
|
||||||
}
|
}
|
||||||
|
if err := dockerCli.Client().PluginInstall(ctx, ref.String(), options); err != nil {
|
||||||
return dockerCli.Client().PluginInstall(ctx, ref.String(), options)
|
return err
|
||||||
|
}
|
||||||
|
fmt.Fprintln(dockerCli.Out(), opts.name)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func acceptPrivileges(dockerCli *client.DockerCli, name string) func(privileges types.PluginPrivileges) (bool, error) {
|
func acceptPrivileges(dockerCli *client.DockerCli, name string) func(privileges types.PluginPrivileges) (bool, error) {
|
||||||
|
|
|
@ -3,54 +3,63 @@ package main
|
||||||
import (
|
import (
|
||||||
"github.com/docker/docker/pkg/integration/checker"
|
"github.com/docker/docker/pkg/integration/checker"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
|
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
pName = "tiborvass/no-remove"
|
||||||
|
pTag = "latest"
|
||||||
|
pNameWithTag = pName + ":" + pTag
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
||||||
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
||||||
name := "tiborvass/no-remove"
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
||||||
tag := "latest"
|
|
||||||
nameWithTag := name + ":" + tag
|
|
||||||
|
|
||||||
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", name)
|
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(out, checker.Contains, name)
|
c.Assert(out, checker.Contains, pName)
|
||||||
c.Assert(out, checker.Contains, tag)
|
c.Assert(out, checker.Contains, pTag)
|
||||||
c.Assert(out, checker.Contains, "true")
|
c.Assert(out, checker.Contains, "true")
|
||||||
|
|
||||||
out, _, err = dockerCmdWithError("plugin", "inspect", nameWithTag)
|
out, _, err = dockerCmdWithError("plugin", "inspect", pNameWithTag)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(out, checker.Contains, "A test plugin for Docker")
|
c.Assert(out, checker.Contains, "A test plugin for Docker")
|
||||||
|
|
||||||
out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||||
c.Assert(out, checker.Contains, "is active")
|
c.Assert(out, checker.Contains, "is active")
|
||||||
|
|
||||||
_, _, err = dockerCmdWithError("plugin", "disable", nameWithTag)
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(out, checker.Contains, nameWithTag)
|
c.Assert(out, checker.Contains, pNameWithTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
||||||
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
|
||||||
name := "tiborvass/no-remove"
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
||||||
tag := "latest"
|
|
||||||
nameWithTag := name + ":" + tag
|
|
||||||
|
|
||||||
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", name)
|
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
||||||
|
|
||||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(out, checker.Contains, "false")
|
c.Assert(out, checker.Contains, "false")
|
||||||
|
|
||||||
out, _, err = dockerCmdWithError("plugin", "remove", nameWithTag)
|
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(out, checker.Contains, nameWithTag)
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
||||||
|
|
||||||
|
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
||||||
|
|
||||||
|
out, _, err = dockerCmdWithError("plugin", "remove", pName)
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestPluginInstallImage(c *check.C) {
|
func (s *DockerSuite) TestPluginInstallImage(c *check.C) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue