From 58028a2919f1ee794a058fb3451a5145a6382b4d Mon Sep 17 00:00:00 2001 From: Yanqiang Miao Date: Tue, 22 Nov 2016 19:40:54 +0800 Subject: [PATCH] Eliminate redundant parameters Signed-off-by: Yanqiang Miao update Signed-off-by: Yanqiang Miao --- container/container.go | 9 +++++---- daemon/logs.go | 2 +- integration-cli/docker_cli_run_test.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/container/container.go b/container/container.go index e0a9da424d..4634e5348c 100644 --- a/container/container.go +++ b/container/container.go @@ -322,10 +322,11 @@ func (container *Container) CheckpointDir() string { } // StartLogger starts a new logger driver for the container. -func (container *Container) StartLogger(cfg containertypes.LogConfig) (logger.Logger, error) { +func (container *Container) StartLogger() (logger.Logger, error) { + cfg := container.HostConfig.LogConfig c, err := logger.GetLogDriver(cfg.Type) if err != nil { - return nil, fmt.Errorf("Failed to get logging factory: %v", err) + return nil, fmt.Errorf("failed to get logging factory: %v", err) } ctx := logger.Context{ Config: cfg.Config, @@ -1050,9 +1051,9 @@ func (container *Container) startLogging() error { return nil // do not start logging routines } - l, err := container.StartLogger(container.HostConfig.LogConfig) + l, err := container.StartLogger() if err != nil { - return fmt.Errorf("Failed to initialize logging driver: %v", err) + return fmt.Errorf("failed to initialize logging driver: %v", err) } copier := logger.NewCopier(map[string]io.Reader{"stdout": container.StdoutPipe(), "stderr": container.StderrPipe()}, l) diff --git a/daemon/logs.go b/daemon/logs.go index cc34b82083..32a6938869 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -117,7 +117,7 @@ func (daemon *Daemon) getLogger(container *container.Container) (logger.Logger, if container.LogDriver != nil && container.IsRunning() { return container.LogDriver, nil } - return container.StartLogger(container.HostConfig.LogConfig) + return container.StartLogger() } // mergeLogConfig merges the daemon log config to the container's log config if the container's log driver is not specified. diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 033d03a6b9..c4a8947a67 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -4515,7 +4515,7 @@ func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *check.C) { out, _, err := dockerCmdWithError("run", "--name=fail", "--log-driver=splunk", "busybox", "true") c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "Failed to initialize logging driver", check.Commentf("error should be about logging driver, got output %s", out)) + c.Assert(out, checker.Contains, "failed to initialize logging driver", check.Commentf("error should be about logging driver, got output %s", out)) // NGoroutines is not updated right away, so we need to wait before failing c.Assert(waitForGoroutines(nroutines), checker.IsNil)