update eventlogger dep which should eliminate a possible panic with the gated.Broker is nil (#1411)
This commit is contained in:
6 files changed
+32
-18
No files matched your search
@@ -3,7 +3,7 @@ package event
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/eventlogger"
|
||||
"github.com/hashicorp/eventlogger/filters/gated"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
const observationVersion = "v0.1"
|
||||
|
||||
type observation struct {
|
||||
*eventlogger.SimpleGatedPayload
|
||||
*gated.Payload
|
||||
Version string `json:"version"`
|
||||
Op Op `json:"op,omitempty"`
|
||||
RequestInfo *RequestInfo `json:"request_info,omitempty"`
|
||||
@@ -36,7 +36,7 @@ func newObservation(fromOperation Op, opt ...Option) (*observation, error) {
|
||||
}
|
||||
}
|
||||
i := &observation{
|
||||
SimpleGatedPayload: &eventlogger.SimpleGatedPayload{
|
||||
Payload: &gated.Payload{
|
||||
ID: opts.withId,
|
||||
Header: opts.withHeader,
|
||||
Detail: opts.withDetails,
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/eventlogger"
|
||||
"github.com/hashicorp/eventlogger/filters/gated"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -40,9 +40,9 @@ func Test_newObservation(t *testing.T) {
|
||||
name: "valid-no-opts",
|
||||
fromOp: Op("valid-no-opts"),
|
||||
want: &observation{
|
||||
SimpleGatedPayload: &eventlogger.SimpleGatedPayload{},
|
||||
Version: errorVersion,
|
||||
Op: Op("valid-no-opts"),
|
||||
Payload: &gated.Payload{},
|
||||
Version: errorVersion,
|
||||
Op: Op("valid-no-opts"),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -56,7 +56,7 @@ func Test_newObservation(t *testing.T) {
|
||||
WithFlush(),
|
||||
},
|
||||
want: &observation{
|
||||
SimpleGatedPayload: &eventlogger.SimpleGatedPayload{
|
||||
Payload: &gated.Payload{
|
||||
ID: "valid-all-opts",
|
||||
Header: testHeader,
|
||||
Detail: testDetails,
|
||||
@@ -124,7 +124,7 @@ func Test_observationvalidate(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
e := observation{
|
||||
Op: tt.op,
|
||||
SimpleGatedPayload: &eventlogger.SimpleGatedPayload{
|
||||
Payload: &gated.Payload{
|
||||
ID: tt.id,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/eventlogger"
|
||||
"github.com/hashicorp/eventlogger/filters/gated"
|
||||
"github.com/hashicorp/eventlogger/sinks/writer"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
@@ -191,7 +193,7 @@ func NewEventer(log hclog.Logger, serializationLock *sync.Mutex, c EventerConfig
|
||||
var sinkNode eventlogger.Node
|
||||
switch s.SinkType {
|
||||
case StderrSink:
|
||||
sinkNode = &eventlogger.WriterSink{
|
||||
sinkNode = &writer.Sink{
|
||||
Format: string(s.Format),
|
||||
Writer: &serializedStderr,
|
||||
}
|
||||
@@ -283,7 +285,9 @@ func NewEventer(log hclog.Logger, serializationLock *sync.Mutex, c EventerConfig
|
||||
}
|
||||
|
||||
for _, p := range auditPipelines {
|
||||
gatedFilterNode := eventlogger.GatedFilter{}
|
||||
gatedFilterNode := gated.Filter{
|
||||
Broker: e.broker,
|
||||
}
|
||||
e.flushableNodes = append(e.flushableNodes, &gatedFilterNode)
|
||||
gateId, err := newId("gated-audit")
|
||||
if err != nil {
|
||||
@@ -309,7 +313,9 @@ func NewEventer(log hclog.Logger, serializationLock *sync.Mutex, c EventerConfig
|
||||
}
|
||||
|
||||
for _, p := range observationPipelines {
|
||||
gatedFilterNode := eventlogger.GatedFilter{}
|
||||
gatedFilterNode := gated.Filter{
|
||||
Broker: e.broker,
|
||||
}
|
||||
e.flushableNodes = append(e.flushableNodes, &gatedFilterNode)
|
||||
gateId, err := newId("gated-observation")
|
||||
if err != nil {
|
||||
@@ -414,7 +420,7 @@ func (e *Eventer) writeObservation(ctx context.Context, event *observation) erro
|
||||
if event.Detail != nil {
|
||||
event.Detail[OpField] = string(event.Op)
|
||||
}
|
||||
return e.broker.Send(ctx, eventlogger.EventType(ObservationType), event.SimpleGatedPayload)
|
||||
return e.broker.Send(ctx, eventlogger.EventType(ObservationType), event.Payload)
|
||||
})
|
||||
if err != nil {
|
||||
e.logger.Error("encountered an error sending an observation event", "error:", err.Error())
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/eventlogger"
|
||||
"github.com/hashicorp/eventlogger/filters/gated"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -482,7 +483,7 @@ type testMockBroker struct {
|
||||
func (b *testMockBroker) Send(ctx context.Context, t eventlogger.EventType, payload interface{}) (eventlogger.Status, error) {
|
||||
const op = "common.(testMockBroker).Send"
|
||||
switch {
|
||||
case b.errorOnFlush && payload.(eventlogger.Gateable).FlushEvent():
|
||||
case b.errorOnFlush && payload.(gated.Gateable).FlushEvent():
|
||||
return eventlogger.Status{}, errors.New(errors.Internal, op, "unable to flush event")
|
||||
case b.errorOnSendAudit && t == eventlogger.EventType(event.AuditType):
|
||||
return eventlogger.Status{}, errors.New(errors.Internal, op, "unable to send audit event")
|
||||
|
||||
Reference in new issue
Block a user