This is required for swarmkit to be able to filter based on log driver.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -90,6 +90,10 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error {
|
| 90 | 90 |
fmt.Fprintf(dockerCli.Out(), "\n") |
| 91 | 91 |
} |
| 92 | 92 |
|
| 93 |
+ fmt.Fprintf(dockerCli.Out(), " Log:") |
|
| 94 |
+ fmt.Fprintf(dockerCli.Out(), " %s", strings.Join(info.Plugins.Log, " ")) |
|
| 95 |
+ fmt.Fprintf(dockerCli.Out(), "\n") |
|
| 96 |
+ |
|
| 93 | 97 |
fmt.Fprintf(dockerCli.Out(), "Swarm: %v\n", info.Swarm.LocalNodeState) |
| 94 | 98 |
if info.Swarm.LocalNodeState != swarm.LocalNodeStateInactive && info.Swarm.LocalNodeState != swarm.LocalNodeStateLocked {
|
| 95 | 99 |
fmt.Fprintf(dockerCli.Out(), " NodeID: %s\n", info.Swarm.NodeID) |
| ... | ... |
@@ -52,6 +52,7 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
| 52 | 52 |
// the plugin list by default. |
| 53 | 53 |
addPlugins("Network", append([]string{"overlay"}, info.Plugins.Network...))
|
| 54 | 54 |
addPlugins("Authorization", info.Plugins.Authorization)
|
| 55 |
+ addPlugins("Log", info.Plugins.Log)
|
|
| 55 | 56 |
|
| 56 | 57 |
// add v2 plugins |
| 57 | 58 |
v2Plugins, err := e.backend.PluginManager().List(filters.NewArgs()) |
| ... | ... |
@@ -62,11 +63,15 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
| 62 | 62 |
continue |
| 63 | 63 |
} |
| 64 | 64 |
plgnTyp := typ.Capability |
| 65 |
- if typ.Capability == "volumedriver" {
|
|
| 65 |
+ switch typ.Capability {
|
|
| 66 |
+ case "volumedriver": |
|
| 66 | 67 |
plgnTyp = "Volume" |
| 67 |
- } else if typ.Capability == "networkdriver" {
|
|
| 68 |
+ case "networkdriver": |
|
| 68 | 69 |
plgnTyp = "Network" |
| 70 |
+ case "logdriver": |
|
| 71 |
+ plgnTyp = "Log" |
|
| 69 | 72 |
} |
| 73 |
+ |
|
| 70 | 74 |
plugins[api.PluginDescription{
|
| 71 | 75 |
Type: plgnTyp, |
| 72 | 76 |
Name: plgn.Name, |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/api/types" |
| 13 | 13 |
"github.com/docker/docker/cli/debug" |
| 14 | 14 |
"github.com/docker/docker/container" |
| 15 |
+ "github.com/docker/docker/daemon/logger" |
|
| 15 | 16 |
"github.com/docker/docker/dockerversion" |
| 16 | 17 |
"github.com/docker/docker/pkg/fileutils" |
| 17 | 18 |
"github.com/docker/docker/pkg/parsers/kernel" |
| ... | ... |
@@ -175,6 +176,7 @@ func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
|
| 175 | 175 |
pluginsInfo.Volume = volumedrivers.GetDriverList() |
| 176 | 176 |
pluginsInfo.Network = daemon.GetNetworkDriverList() |
| 177 | 177 |
pluginsInfo.Authorization = daemon.configStore.GetAuthorizationPlugins() |
| 178 |
+ pluginsInfo.Log = logger.ListDrivers() |
|
| 178 | 179 |
|
| 179 | 180 |
return pluginsInfo |
| 180 | 181 |
} |
| ... | ... |
@@ -2,6 +2,7 @@ package logger |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
+ "sort" |
|
| 5 | 6 |
"sync" |
| 6 | 7 |
|
| 7 | 8 |
containertypes "github.com/docker/docker/api/types/container" |
| ... | ... |
@@ -23,6 +24,22 @@ type logdriverFactory struct {
|
| 23 | 23 |
m sync.Mutex |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
+func (lf *logdriverFactory) list() []string {
|
|
| 27 |
+ ls := make([]string, 0, len(lf.registry)) |
|
| 28 |
+ lf.m.Lock() |
|
| 29 |
+ for name := range lf.registry {
|
|
| 30 |
+ ls = append(ls, name) |
|
| 31 |
+ } |
|
| 32 |
+ lf.m.Unlock() |
|
| 33 |
+ sort.Strings(ls) |
|
| 34 |
+ return ls |
|
| 35 |
+} |
|
| 36 |
+ |
|
| 37 |
+// ListDrivers gets the list of registered log driver names |
|
| 38 |
+func ListDrivers() []string {
|
|
| 39 |
+ return factory.list() |
|
| 40 |
+} |
|
| 41 |
+ |
|
| 26 | 42 |
func (lf *logdriverFactory) register(name string, c Creator) error {
|
| 27 | 43 |
if lf.driverRegistered(name) {
|
| 28 | 44 |
return fmt.Errorf("logger: log driver named '%s' is already registered", name)
|
| ... | ... |
@@ -1,9 +1,13 @@ |
| 1 | 1 |
package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "encoding/json" |
|
| 5 |
+ "net/http" |
|
| 4 | 6 |
"strings" |
| 5 | 7 |
|
| 8 |
+ "github.com/docker/docker/api/types" |
|
| 6 | 9 |
"github.com/docker/docker/integration-cli/checker" |
| 10 |
+ "github.com/docker/docker/integration-cli/request" |
|
| 7 | 11 |
"github.com/go-check/check" |
| 8 | 12 |
) |
| 9 | 13 |
|
| ... | ... |
@@ -25,3 +29,21 @@ func (s *DockerSuite) TestPluginLogDriver(c *check.C) {
|
| 25 | 25 |
dockerCmd(c, "plugin", "disable", pluginName) |
| 26 | 26 |
dockerCmd(c, "plugin", "rm", pluginName) |
| 27 | 27 |
} |
| 28 |
+ |
|
| 29 |
+// Make sure log drivers are listed in info, and v2 plugins are not. |
|
| 30 |
+func (s *DockerSuite) TestPluginLogDriverInfoList(c *check.C) {
|
|
| 31 |
+ testRequires(c, IsAmd64, DaemonIsLinux) |
|
| 32 |
+ pluginName := "cpuguy83/docker-logdriver-test" |
|
| 33 |
+ |
|
| 34 |
+ dockerCmd(c, "plugin", "install", pluginName) |
|
| 35 |
+ status, body, err := request.SockRequest("GET", "/info", nil, daemonHost())
|
|
| 36 |
+ c.Assert(status, checker.Equals, http.StatusOK) |
|
| 37 |
+ c.Assert(err, checker.IsNil) |
|
| 38 |
+ |
|
| 39 |
+ var info types.Info |
|
| 40 |
+ err = json.Unmarshal(body, &info) |
|
| 41 |
+ c.Assert(err, checker.IsNil) |
|
| 42 |
+ drivers := strings.Join(info.Plugins.Log, " ") |
|
| 43 |
+ c.Assert(drivers, checker.Contains, "json-file") |
|
| 44 |
+ c.Assert(drivers, checker.Not(checker.Contains), pluginName) |
|
| 45 |
+} |