From cf4e268115911e9e4a4da94dc00b2dc370f86a47 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 4 Aug 2016 16:19:46 -0700 Subject: [PATCH] replace active by enabled for consistency in plugins Signed-off-by: Victor Vieux --- api/client/plugin/list.go | 4 ++-- docs/reference/commandline/plugin_disable.md | 10 +++------- docs/reference/commandline/plugin_enable.md | 10 +++------- docs/reference/commandline/plugin_inspect.md | 2 +- docs/reference/commandline/plugin_install.md | 2 +- docs/reference/commandline/plugin_ls.md | 2 +- docs/reference/commandline/plugin_rm.md | 2 +- hack/vendor.sh | 2 +- integration-cli/docker_cli_plugins_test.go | 4 ++-- plugin/manager.go | 8 ++++---- plugin/manager_linux.go | 14 +++++++------- .../github.com/docker/engine-api/types/plugin.go | 9 +++++---- 12 files changed, 31 insertions(+), 38 deletions(-) diff --git a/api/client/plugin/list.go b/api/client/plugin/list.go index 8ff16f984f..66c6e881ef 100644 --- a/api/client/plugin/list.go +++ b/api/client/plugin/list.go @@ -45,7 +45,7 @@ func runList(dockerCli *client.DockerCli, opts listOptions) error { } w := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 3, ' ', 0) - fmt.Fprintf(w, "NAME \tTAG \tDESCRIPTION\tACTIVE") + fmt.Fprintf(w, "NAME \tTAG \tDESCRIPTION\tENABLED") fmt.Fprintf(w, "\n") for _, p := range plugins { @@ -55,7 +55,7 @@ func runList(dockerCli *client.DockerCli, opts listOptions) error { desc = stringutils.Ellipsis(desc, 45) } - fmt.Fprintf(w, "%s\t%s\t%s\t%v\n", p.Name, p.Tag, desc, p.Active) + fmt.Fprintf(w, "%s\t%s\t%s\t%v\n", p.Name, p.Tag, desc, p.Enabled) } w.Flush() return nil diff --git a/docs/reference/commandline/plugin_disable.md b/docs/reference/commandline/plugin_disable.md index a3b2b8868e..eae31975e1 100644 --- a/docs/reference/commandline/plugin_disable.md +++ b/docs/reference/commandline/plugin_disable.md @@ -25,12 +25,12 @@ see [`docker plugin install`](plugin_install.md). The following example shows that the `no-remove` plugin is installed -and active: +and enabled: ```bash $ docker plugin ls -NAME TAG DESCRIPTION ACTIVE +NAME TAG DESCRIPTION ENABLED tiborvass/no-remove latest A test plugin for Docker true ``` @@ -40,14 +40,10 @@ To disable the plugin, use the following command: $ docker plugin disable tiborvass/no-remove tiborvass/no-remove -``` -After the plugin is disabled, it appears as "inactive" in the list of plugins: - -```bash $ docker plugin ls -NAME TAG DESCRIPTION ACTIVE +NAME TAG DESCRIPTION ENABLED tiborvass/no-remove latest A test plugin for Docker false ``` diff --git a/docs/reference/commandline/plugin_enable.md b/docs/reference/commandline/plugin_enable.md index 91f85b0fa4..44ef3c2fa3 100644 --- a/docs/reference/commandline/plugin_enable.md +++ b/docs/reference/commandline/plugin_enable.md @@ -25,12 +25,12 @@ see [`docker plugin install`](plugin_install.md). The following example shows that the `no-remove` plugin is installed, -but disabled ("inactive"): +but disabled: ```bash $ docker plugin ls -NAME TAG DESCRIPTION ACTIVE +NAME TAG DESCRIPTION ENABLED tiborvass/no-remove latest A test plugin for Docker false ``` @@ -40,14 +40,10 @@ To enable the plugin, use the following command: $ docker plugin enable tiborvass/no-remove tiborvass/no-remove -``` -After the plugin is enabled, it appears as "active" in the list of plugins: - -```bash $ docker plugin ls -NAME TAG DESCRIPTION ACTIVE +NAME TAG DESCRIPTION ENABLED tiborvass/no-remove latest A test plugin for Docker true ``` diff --git a/docs/reference/commandline/plugin_inspect.md b/docs/reference/commandline/plugin_inspect.md index 80da2dcd0e..17993d573b 100644 --- a/docs/reference/commandline/plugin_inspect.md +++ b/docs/reference/commandline/plugin_inspect.md @@ -33,7 +33,7 @@ $ docker plugin inspect tiborvass/no-remove:latest "Id": "8c74c978c434745c3ade82f1bc0acf38d04990eaf494fa507c16d9f1daa99c21", "Name": "tiborvass/no-remove", "Tag": "latest", - "Active": true, + "Enabled": true, "Config": { "Mounts": [ { diff --git a/docs/reference/commandline/plugin_install.md b/docs/reference/commandline/plugin_install.md index 085714e067..3dc4869d36 100644 --- a/docs/reference/commandline/plugin_install.md +++ b/docs/reference/commandline/plugin_install.md @@ -47,7 +47,7 @@ After the plugin is installed, it appears in the list of plugins: ```bash $ docker plugin ls -NAME TAG DESCRIPTION ACTIVE +NAME TAG DESCRIPTION ENABLED tiborvass/no-remove latest A test plugin for Docker true ``` diff --git a/docs/reference/commandline/plugin_ls.md b/docs/reference/commandline/plugin_ls.md index f94d80d0cc..77999bc1b4 100644 --- a/docs/reference/commandline/plugin_ls.md +++ b/docs/reference/commandline/plugin_ls.md @@ -32,7 +32,7 @@ Example output: ```bash $ docker plugin ls -NAME TAG DESCRIPTION ACTIVE +NAME TAG DESCRIPTION ENABLED tiborvass/no-remove latest A test plugin for Docker true ``` diff --git a/docs/reference/commandline/plugin_rm.md b/docs/reference/commandline/plugin_rm.md index 6535b5e102..d78f8bd712 100644 --- a/docs/reference/commandline/plugin_rm.md +++ b/docs/reference/commandline/plugin_rm.md @@ -24,7 +24,7 @@ Options: --help Print usage ``` -Removes a plugin. You cannot remove a plugin if it is active, you must disable +Removes a plugin. You cannot remove a plugin if it is enabled, you must disable a plugin using the [`docker plugin disable`](plugin_disable.md) before removing it (or use --force, use of force is not recommended, since it can affect functioning of running containers using the plugin). diff --git a/hack/vendor.sh b/hack/vendor.sh index 5e1fa5897b..a69601d95e 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -61,7 +61,7 @@ clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://gith clone git github.com/docker/go-units eb879ae3e2b84e2a142af415b679ddeda47ec71c clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d -clone git github.com/docker/engine-api ebc51d1954fc8934307dd15841b8d64f7cd505df +clone git github.com/docker/engine-api 94a8f8f29307ab291abad6c6f2182d67089aae5d clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837 clone git github.com/imdario/mergo 0.2.1 diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go index e16d8e0017..932d139ba7 100644 --- a/integration-cli/docker_cli_plugins_test.go +++ b/integration-cli/docker_cli_plugins_test.go @@ -42,7 +42,7 @@ func (s *DockerSuite) TestPluginBasicOps(c *check.C) { c.Assert(err, checker.IsNil) out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) - c.Assert(out, checker.Contains, "is active") + c.Assert(out, checker.Contains, "is enabled") _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag) c.Assert(err, checker.IsNil) @@ -63,7 +63,7 @@ func (s *DockerSuite) TestPluginForceRemove(c *check.C) { c.Assert(err, checker.IsNil) out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) - c.Assert(out, checker.Contains, "is active") + c.Assert(out, checker.Contains, "is enabled") out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag) c.Assert(err, checker.IsNil) diff --git a/plugin/manager.go b/plugin/manager.go index f292c09a5e..8fde1ffd7b 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -84,7 +84,7 @@ func (pm *Manager) newPlugin(ref reference.Named, id string) *plugin { func (pm *Manager) restorePlugin(p *plugin) error { p.runtimeSourcePath = filepath.Join(pm.runRoot, p.PluginObj.ID) - if p.PluginObj.Active { + if p.PluginObj.Enabled { return pm.restore(p) } return nil @@ -321,7 +321,7 @@ func (pm *Manager) init() error { pm.Lock() pm.nameToID[p.Name()] = p.PluginObj.ID - requiresManualRestore := !pm.liveRestore && p.PluginObj.Active + requiresManualRestore := !pm.liveRestore && p.PluginObj.Enabled pm.Unlock() if requiresManualRestore { @@ -369,9 +369,9 @@ func (pm *Manager) initPlugin(p *plugin) error { } func (pm *Manager) remove(p *plugin, force bool) error { - if p.PluginObj.Active { + if p.PluginObj.Enabled { if !force { - return fmt.Errorf("plugin %s is active", p.Name()) + return fmt.Errorf("plugin %s is enabled", p.Name()) } if err := pm.disable(p); err != nil { logrus.Errorf("failed to disable plugin '%s': %s", p.Name(), err) diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go index b9ae328626..d87fd34173 100644 --- a/plugin/manager_linux.go +++ b/plugin/manager_linux.go @@ -21,7 +21,7 @@ import ( ) func (pm *Manager) enable(p *plugin, force bool) error { - if p.PluginObj.Active && !force { + if p.PluginObj.Enabled && !force { return fmt.Errorf("plugin %s is already enabled", p.Name()) } spec, err := pm.initSpec(p) @@ -47,7 +47,7 @@ func (pm *Manager) enable(p *plugin, force bool) error { } pm.Lock() // fixme: lock single record - p.PluginObj.Active = true + p.PluginObj.Enabled = true pm.save() pm.Unlock() @@ -130,7 +130,7 @@ func (pm *Manager) initSpec(p *plugin) (*specs.Spec, error) { } func (pm *Manager) disable(p *plugin) error { - if !p.PluginObj.Active { + if !p.PluginObj.Enabled { return fmt.Errorf("plugin %s is already disabled", p.Name()) } if err := p.restartManager.Cancel(); err != nil { @@ -142,7 +142,7 @@ func (pm *Manager) disable(p *plugin) error { os.RemoveAll(p.runtimeSourcePath) pm.Lock() // fixme: lock single record defer pm.Unlock() - p.PluginObj.Active = false + p.PluginObj.Enabled = false pm.save() return nil } @@ -156,8 +156,8 @@ func (pm *Manager) Shutdown() { pm.RLock() defer pm.RUnlock() for _, p := range pm.plugins { - if pm.liveRestore && p.PluginObj.Active { - logrus.Debug("Plugin active when liveRestore is set, skipping shutdown") + if pm.liveRestore && p.PluginObj.Enabled { + logrus.Debug("Plugin enabled when liveRestore is set, skipping shutdown") continue } if p.restartManager != nil { @@ -165,7 +165,7 @@ func (pm *Manager) Shutdown() { logrus.Error(err) } } - if pm.containerdClient != nil && p.PluginObj.Active { + if pm.containerdClient != nil && p.PluginObj.Enabled { p.exitChan = make(chan bool) err := pm.containerdClient.Signal(p.PluginObj.ID, int(syscall.SIGTERM)) if err != nil { diff --git a/vendor/src/github.com/docker/engine-api/types/plugin.go b/vendor/src/github.com/docker/engine-api/types/plugin.go index 05030ff3de..601c0ac12a 100644 --- a/vendor/src/github.com/docker/engine-api/types/plugin.go +++ b/vendor/src/github.com/docker/engine-api/types/plugin.go @@ -26,10 +26,11 @@ type PluginConfig struct { // Plugin represents a Docker plugin for the remote API type Plugin struct { - ID string `json:"Id,omitempty"` - Name string - Tag string - Active bool + ID string `json:"Id,omitempty"` + Name string + Tag string + // Enabled is true when the plugin is running, is false when the plugin is not running, only installed. + Enabled bool Config PluginConfig Manifest PluginManifest }