Skip to content

Commit

Permalink
Merge pull request #2538 from sheerun/patch1
Browse files Browse the repository at this point in the history
Remove unnecessary parameter from NewHTTPServer
  • Loading branch information
dadgar authored Apr 10, 2017
2 parents db11e7d + 4d46509 commit 83be4ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer) error {
}

// Setup the HTTP server
http, err := NewHTTPServer(agent, config, logOutput)
http, err := NewHTTPServer(agent, config)
if err != nil {
agent.Shutdown()
c.Ui.Error(fmt.Sprintf("Error starting http server: %s", err))
Expand Down
3 changes: 1 addition & 2 deletions command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -52,7 +51,7 @@ type HTTPServer struct {
}

// NewHTTPServer starts new HTTP server over the agent
func NewHTTPServer(agent *Agent, config *Config, logOutput io.Writer) (*HTTPServer, error) {
func NewHTTPServer(agent *Agent, config *Config) (*HTTPServer, error) {
// Start the listener
lnAddr, err := net.ResolveTCPAddr("tcp", config.normalizedAddrs.HTTP)
if err != nil {
Expand Down
22 changes: 4 additions & 18 deletions command/agent/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,11 @@ func (s *TestServer) Cleanup() {
os.RemoveAll(s.Dir)
}

// makeHTTPServerNoLogs returns a test server with full logging.
func makeHTTPServer(t testing.TB, cb func(c *Config)) *TestServer {
return makeHTTPServerWithWriter(t, nil, cb)
}

// makeHTTPServerNoLogs returns a test server which only prints agent logs and
// no http server logs
func makeHTTPServerNoLogs(t testing.TB, cb func(c *Config)) *TestServer {
return makeHTTPServerWithWriter(t, ioutil.Discard, cb)
}

// makeHTTPServerWithWriter returns a test server whose logs will be written to
// makeHTTPServer returns a test server whose logs will be written to
// the passed writer. If the writer is nil, the logs are written to stderr.
func makeHTTPServerWithWriter(t testing.TB, w io.Writer, cb func(c *Config)) *TestServer {
func makeHTTPServer(t testing.TB, cb func(c *Config)) *TestServer {
dir, agent := makeAgent(t, cb)
if w == nil {
w = agent.logOutput
}
srv, err := NewHTTPServer(agent, agent.config, w)
srv, err := NewHTTPServer(agent, agent.config)
if err != nil {
t.Fatalf("err: %v", err)
}
Expand All @@ -63,7 +49,7 @@ func makeHTTPServerWithWriter(t testing.TB, w io.Writer, cb func(c *Config)) *Te
}

func BenchmarkHTTPRequests(b *testing.B) {
s := makeHTTPServerNoLogs(b, func(c *Config) {
s := makeHTTPServer(b, func(c *Config) {
c.Client.Enabled = false
})
defer s.Cleanup()
Expand Down

0 comments on commit 83be4ad

Please sign in to comment.