Remove unnecessary parameter from NewHTTPServer
This commit is contained in:
parent
d2a64d3fd3
commit
4daf4cb8c9
|
@ -350,7 +350,7 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the HTTP server
|
// Setup the HTTP server
|
||||||
http, err := NewHTTPServer(agent, config, logOutput)
|
http, err := NewHTTPServer(agent, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
agent.Shutdown()
|
agent.Shutdown()
|
||||||
c.Ui.Error(fmt.Sprintf("Error starting http server: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error starting http server: %s", err))
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -52,7 +51,7 @@ type HTTPServer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHTTPServer starts new HTTP server over the agent
|
// 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
|
// Start the listener
|
||||||
lnAddr, err := net.ResolveTCPAddr("tcp", config.normalizedAddrs.HTTP)
|
lnAddr, err := net.ResolveTCPAddr("tcp", config.normalizedAddrs.HTTP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -31,25 +31,11 @@ func (s *TestServer) Cleanup() {
|
||||||
os.RemoveAll(s.Dir)
|
os.RemoveAll(s.Dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeHTTPServerNoLogs returns a test server with full logging.
|
// makeHTTPServer returns a test server whose logs will be written to
|
||||||
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
|
|
||||||
// the passed writer. If the writer is nil, the logs are written to stderr.
|
// 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)
|
dir, agent := makeAgent(t, cb)
|
||||||
if w == nil {
|
srv, err := NewHTTPServer(agent, agent.config)
|
||||||
w = agent.logOutput
|
|
||||||
}
|
|
||||||
srv, err := NewHTTPServer(agent, agent.config, w)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -63,7 +49,7 @@ func makeHTTPServerWithWriter(t testing.TB, w io.Writer, cb func(c *Config)) *Te
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkHTTPRequests(b *testing.B) {
|
func BenchmarkHTTPRequests(b *testing.B) {
|
||||||
s := makeHTTPServerNoLogs(b, func(c *Config) {
|
s := makeHTTPServer(b, func(c *Config) {
|
||||||
c.Client.Enabled = false
|
c.Client.Enabled = false
|
||||||
})
|
})
|
||||||
defer s.Cleanup()
|
defer s.Cleanup()
|
||||||
|
|
Loading…
Reference in New Issue