allow all build contexts to use noOpAuditor

This commit is contained in:
Drew Bailey
2020-03-25 10:38:40 -04:00
parent 8edf55600b
commit 80965716b6
2 changed files with 24 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
package agent
import (
"context"
"fmt"
"io"
"io/ioutil"
@@ -1081,3 +1082,26 @@ func (a *Agent) setupConsul(consulConfig *config.ConsulConfig) error {
go a.consulService.Run()
return nil
}
// noOpAuditor is a no-op Auditor that fulfills the
// event.Auditor interface.
type noOpAuditor struct{}
// Ensure noOpAuditor is an Auditor
var _ event.Auditor = &noOpAuditor{}
func (e *noOpAuditor) Event(ctx context.Context, eventType string, payload interface{}) error {
return nil
}
func (e *noOpAuditor) Enabled() bool {
return false
}
func (e *noOpAuditor) Reopen() error {
return nil
}
func (e *noOpAuditor) SetEnabled(enabled bool) {}
func (e *noOpAuditor) DeliveryEnforced() bool { return false }

View File

@@ -3,34 +3,10 @@
package agent
import (
"context"
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/command/agent/event"
"github.com/hashicorp/nomad/nomad/structs/config"
)
type noOpAuditor struct{}
// Ensure noOpAuditor is an Eventer
var _ event.Auditor = &noOpAuditor{}
func (e *noOpAuditor) Event(ctx context.Context, eventType string, payload interface{}) error {
return nil
}
func (e *noOpAuditor) Enabled() bool {
return false
}
func (e *noOpAuditor) Reopen() error {
return nil
}
func (e *noOpAuditor) SetEnabled(enabled bool) {}
func (e *noOpAuditor) DeliveryEnforced() bool { return false }
func (a *Agent) setupEnterpriseAgent(log hclog.Logger) error {
// configure eventer
a.auditor = &noOpAuditor{}