diff --git a/command/agent/event/event.go b/command/agent/event/event.go index 4cff3a2f559..2f1ac247ecd 100644 --- a/command/agent/event/event.go +++ b/command/agent/event/event.go @@ -6,10 +6,10 @@ import ( // Auditor describes the interface that must be implemented by an eventer. type Auditor interface { - // Emit an event to the auditor + // Event emits an event to the auditor. Event(ctx context.Context, eventType string, payload interface{}) error - // Specifies if the auditor is enabled or not + // Enabled details if the auditor is enabled or not. Enabled() bool // Reopen signals to auditor to reopen any files they have open. diff --git a/command/agent/http.go b/command/agent/http.go index b51d6696a47..94f3bac0be9 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -28,6 +28,7 @@ import ( "github.com/hashicorp/nomad/acl" "github.com/hashicorp/nomad/client" + "github.com/hashicorp/nomad/command/agent/event" "github.com/hashicorp/nomad/helper/noxssrw" "github.com/hashicorp/nomad/helper/tlsutil" "github.com/hashicorp/nomad/nomad" @@ -88,7 +89,12 @@ type RPCer interface { // HTTPServer is used to wrap an Agent and expose it over an HTTP interface type HTTPServer struct { - agent RPCer + agent RPCer + + // eventAuditor is the enterprise audit log feature which is needed by the + // HTTP server. + eventAuditor event.Auditor + mux *http.ServeMux listener net.Listener listenerCh chan struct{} @@ -156,13 +162,14 @@ func NewHTTPServers(agent *Agent, config *Config) ([]*HTTPServer, error) { // Create the server srv := &HTTPServer{ - agent: agent, - mux: http.NewServeMux(), - listener: ln, - listenerCh: make(chan struct{}), - logger: agent.httpLogger, - Addr: ln.Addr().String(), - wsUpgrader: wsUpgrader, + agent: agent, + eventAuditor: agent.auditor, + mux: http.NewServeMux(), + listener: ln, + listenerCh: make(chan struct{}), + logger: agent.httpLogger, + Addr: ln.Addr().String(), + wsUpgrader: wsUpgrader, } srv.registerHandlers(config.EnableDebug) @@ -186,13 +193,14 @@ func NewHTTPServers(agent *Agent, config *Config) ([]*HTTPServer, error) { // the builtinDialer and builtinListener will be nil. if agent.builtinDialer != nil && agent.builtinListener != nil { srv := &HTTPServer{ - agent: agent, - mux: http.NewServeMux(), - listener: agent.builtinListener, - listenerCh: make(chan struct{}), - logger: agent.httpLogger, - Addr: "builtin", - wsUpgrader: wsUpgrader, + agent: agent, + eventAuditor: agent.auditor, + mux: http.NewServeMux(), + listener: agent.builtinListener, + listenerCh: make(chan struct{}), + logger: agent.httpLogger, + Addr: "builtin", + wsUpgrader: wsUpgrader, } srv.registerHandlers(config.EnableDebug)