From c47db2c9223531c405aec3bd2a732905e5c19afe Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 11 May 2017 19:27:24 +0200 Subject: [PATCH] agent: drop config argument agent.config and config are identical. --- command/agent/command.go | 2 +- command/agent/http.go | 4 +++- command/agent/http_test.go | 4 ++-- command/util_test.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index 17e52b8b32..faecf04b24 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -466,7 +466,7 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, logWriter *log c.agent = agent if config.Ports.HTTP > 0 || config.Ports.HTTPS > 0 { - servers, err := NewHTTPServers(agent, config, logOutput) + servers, err := NewHTTPServers(agent, logOutput) if err != nil { agent.Shutdown() c.UI.Error(fmt.Sprintf("Error starting http servers: %s", err)) diff --git a/command/agent/http.go b/command/agent/http.go index 69c0e9fb74..7d23416ca1 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -34,11 +34,13 @@ type HTTPServer struct { // NewHTTPServers starts new HTTP servers to provide an interface to // the agent. -func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPServer, error) { +func NewHTTPServers(agent *Agent, logOutput io.Writer) ([]*HTTPServer, error) { if logOutput == nil { return nil, fmt.Errorf("Please provide a valid logOutput(io.Writer)") } + config := agent.config + var servers []*HTTPServer if config.Ports.HTTPS > 0 { diff --git a/command/agent/http_test.go b/command/agent/http_test.go index 6eacd2137d..1d896c6788 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -60,7 +60,7 @@ RECONF: } dir, agent := makeAgentLog(t, conf, l, logWriter) - servers, err := NewHTTPServers(agent, conf, agent.logOutput) + servers, err := NewHTTPServers(agent, agent.logOutput) if err != nil { if configTry < 3 { goto RECONF @@ -160,7 +160,7 @@ func TestHTTPServer_UnixSocket_FileExists(t *testing.T) { defer os.RemoveAll(dir) // Try to start the server with the same path anyways. - if _, err := NewHTTPServers(agent, conf, agent.logOutput); err != nil { + if _, err := NewHTTPServers(agent, agent.logOutput); err != nil { t.Fatalf("err: %s", err) } diff --git a/command/util_test.go b/command/util_test.go index e72814faac..1f4b0e9018 100644 --- a/command/util_test.go +++ b/command/util_test.go @@ -78,7 +78,7 @@ func testAgentWithConfigReload(t *testing.T, cb func(c *agent.Config), reloadCh conf.Addresses.HTTP = "127.0.0.1" httpAddr := fmt.Sprintf("127.0.0.1:%d", conf.Ports.HTTP) - http, err := agent.NewHTTPServers(a, conf, os.Stderr) + http, err := agent.NewHTTPServers(a, os.Stderr) if err != nil { os.RemoveAll(dir) t.Fatalf(fmt.Sprintf("err: %v", err))