From 239a178c58e3e0f179f297d801979ca848d0aa5d Mon Sep 17 00:00:00 2001 From: Luke Marsden Date: Mon, 4 May 2015 11:54:07 +0100 Subject: [PATCH 1/4] Support integer count of plugins in docker cli --- api/client/commands.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/client/commands.go b/api/client/commands.go index c4ce5e01f..3d860bae7 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -514,6 +514,9 @@ func (cli *DockerCli) CmdInfo(args ...string) error { if remoteInfo.Exists("Images") { fmt.Fprintf(cli.out, "Images: %d\n", remoteInfo.GetInt("Images")) } + if remoteInfo.Exists("Plugins") { + fmt.Fprintf(cli.out, "Plugins: %d\n", remoteInfo.GetInt("Plugins")) + } if remoteInfo.Exists("Driver") { fmt.Fprintf(cli.out, "Storage Driver: %s\n", remoteInfo.Get("Driver")) } From 5d5261e2c3524fe1e7a930e0d3b5a0bad8f0ce2a Mon Sep 17 00:00:00 2001 From: Luke Marsden Date: Mon, 4 May 2015 12:32:59 +0100 Subject: [PATCH 2/4] Add count of plugins in docker info output --- daemon/info.go | 2 ++ plugins/repository.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/daemon/info.go b/daemon/info.go index 8eb4358f4..a0f61654f 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/parsers/operatingsystem" "github.com/docker/docker/pkg/system" + "github.com/docker/docker/plugins" "github.com/docker/docker/registry" "github.com/docker/docker/utils" ) @@ -67,6 +68,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status { v := &engine.Env{} v.SetJson("ID", daemon.ID) v.SetInt("Containers", len(daemon.List())) + v.SetInt("Plugins", plugins.Repo.CountPlugins()) v.SetInt("Images", imgcount) v.Set("Driver", daemon.GraphDriver().String()) v.SetJson("DriverStatus", daemon.GraphDriver().Status()) diff --git a/plugins/repository.go b/plugins/repository.go index 7e00e1ab4..eed60fe20 100644 --- a/plugins/repository.go +++ b/plugins/repository.go @@ -38,6 +38,11 @@ func NewRepository() *Repository { } } +func CountPlugins(repository *Repository) int { + // TODO: expand this to include other supported types + return len(repository.GetPlugins("volume")) +} + func (repository *Repository) RegisterPlugin(addr string) error { plugin := &Plugin{addr: addr} resp, err := plugin.handshake() From d676693f1e69891312681ef7d4a7e2703bb2d0ed Mon Sep 17 00:00:00 2001 From: Luke Marsden Date: Mon, 4 May 2015 12:34:23 +0100 Subject: [PATCH 3/4] single typed --- plugins/repository.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/repository.go b/plugins/repository.go index eed60fe20..97ae744d8 100644 --- a/plugins/repository.go +++ b/plugins/repository.go @@ -40,7 +40,8 @@ func NewRepository() *Repository { func CountPlugins(repository *Repository) int { // TODO: expand this to include other supported types - return len(repository.GetPlugins("volume")) + plugins, err := repository.GetPlugins("volume") + return len(plugins) } func (repository *Repository) RegisterPlugin(addr string) error { From a42097aefef3120c12db2e1b33f87a9eb21e3595 Mon Sep 17 00:00:00 2001 From: Luke Marsden Date: Mon, 4 May 2015 12:36:44 +0100 Subject: [PATCH 4/4] spelling it right --- plugins/repository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/repository.go b/plugins/repository.go index 97ae744d8..7dd1c947a 100644 --- a/plugins/repository.go +++ b/plugins/repository.go @@ -38,9 +38,9 @@ func NewRepository() *Repository { } } -func CountPlugins(repository *Repository) int { +func (repository *Repository) CountPlugins() int { // TODO: expand this to include other supported types - plugins, err := repository.GetPlugins("volume") + plugins, _ := repository.GetPlugins("volume") return len(plugins) }