Merge pull request #28714 from thaJeztah/move-logdriver-check-to-daemon

move check for supported drivers to daemon
This commit is contained in:
Brian Goff 2016-12-21 13:47:30 -05:00 committed by GitHub
commit 63677ef495
1 changed files with 5 additions and 15 deletions

View File

@ -1,7 +1,6 @@
package container package container
import ( import (
"fmt"
"io" "io"
"golang.org/x/net/context" "golang.org/x/net/context"
@ -13,11 +12,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var validDrivers = map[string]bool{
"json-file": true,
"journald": true,
}
type logsOptions struct { type logsOptions struct {
follow bool follow bool
since string since string
@ -54,15 +48,6 @@ func NewLogsCommand(dockerCli *command.DockerCli) *cobra.Command {
func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
ctx := context.Background() 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{ options := types.ContainerLogsOptions{
ShowStdout: true, ShowStdout: true,
ShowStderr: true, ShowStderr: true,
@ -78,6 +63,11 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
} }
defer responseBody.Close() defer responseBody.Close()
c, err := dockerCli.Client().ContainerInspect(ctx, opts.container)
if err != nil {
return err
}
if c.Config.Tty { if c.Config.Tty {
_, err = io.Copy(dockerCli.Out(), responseBody) _, err = io.Copy(dockerCli.Out(), responseBody)
} else { } else {