From 2858451cf07fc972c65185f93354340139389be7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 22 Nov 2016 14:51:22 +0100 Subject: [PATCH] remove client-side for supported logging drivers The `docker logs` command performed a client-side check if the container's logging driver was supported. Now that we allow the client to connect to both "older" and "newer" daemon versions, this check is best done daemon-side. This patch remove the check on the client side, and leaves validation to the daemon, which should be the source of truth. Signed-off-by: Sebastiaan van Stijn Upstream-commit: 8246c4949806912961bd3b18a7d9a83ac7959175 Component: cli --- components/cli/command/container/logs.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/components/cli/command/container/logs.go b/components/cli/command/container/logs.go index 3a37cedf43..9f1d9f90dd 100644 --- a/components/cli/command/container/logs.go +++ b/components/cli/command/container/logs.go @@ -1,7 +1,6 @@ package container import ( - "fmt" "io" "golang.org/x/net/context" @@ -13,11 +12,6 @@ import ( "github.com/spf13/cobra" ) -var validDrivers = map[string]bool{ - "json-file": true, - "journald": true, -} - type logsOptions struct { follow bool since string @@ -54,15 +48,6 @@ func NewLogsCommand(dockerCli *command.DockerCli) *cobra.Command { func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { ctx := context.Background() - c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) - if err != nil { - return err - } - - if !validDrivers[c.HostConfig.LogConfig.Type] { - return fmt.Errorf("\"logs\" command is supported only for \"json-file\" and \"journald\" logging drivers (got: %s)", c.HostConfig.LogConfig.Type) - } - options := types.ContainerLogsOptions{ ShowStdout: true, ShowStderr: true, @@ -78,6 +63,11 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { } defer responseBody.Close() + c, err := dockerCli.Client().ContainerInspect(ctx, opts.container) + if err != nil { + return err + } + if c.Config.Tty { _, err = io.Copy(dockerCli.Out(), responseBody) } else {